Multiple lights switch on/off in multiplayer game

Hi guys,

I’m quite a beginer in blueprints and struggling with scripting something that is very easy at first glance.

I want to setup an area, by entering which you switch on mulptiple lights and if you leave it - lights switch off.
I created 2 blueprint actor classes: one for lights and one for the trigger.
Inside the lights class I created a function which toggles the visibility.

And in trigger class I call that function for all lights when pawn begins overlapping the trigger and call it once again when pawn ends overlap.

For single player it works fine. But I’m struggling with replication and number of players calculation in the trigger (so it’s not switching off lights when 2nd player enters the trigger and not switching off lights when one of the player leaves the trigger (and it should be switched on until the last player leaves the trigger).

Will be thankful if you could give me help on how to solve this problem. Thanks in advance

You need to put logic on the server and also make sure that actor is replicated (check “Replicate” option).
Create event and call it for example “TurnOnLightServer”, set Run On Server and check Reliable.
Create another event and call it “TurnOnLightMulticast” set Multicast and check reliable and put your logic for turning lights there.
On your server event call TurnOnLightMulticast event.

Will try that, thanks!