Replication Client-Server won't work

I’m trying to replicate the functioning of a lightswitch that I have on the map, it works fine going from Server to Client, but not the other way around. I have a basic replication flow, where the Server is called and then it calls the Client, on top of that I’m also using RepNotify and printing its values to the screen. By observing the values I could notice that when I press the switch from the Server, the switch moves on both(Client side and Server side) and the value on each side changes to the same as well, but that’s not true when pressing it from the Client. If I do it from the Client, then the switch will move on both sides, but the value only changes on the Client side, which causes inconsistency and bugs. What am I missing?

Property (state) replication only works from server to client, period.

For RPC (event) replication, if an event is triggered on the client side, then the common approach is for the client to call a “Server” RPC to send the “request”, which will then execute the logic on the server, changing state (properties), and if the properties are marked “replicates”, the property values will go through the property replication path and eventually propagated to the relevant clients.

It seems your client click triggers only local logic execution, which changes the value on the client side locally, while the server doesn’t execute any logic to update the value; rather, the client should never update the value by itself locally, it should always send the request to the server (server rpc), and have the server update the value, which will then replicate to client(s) properly

This is what I’ve been trying:

I have an event on the BP_LighSwitch Blueprint that interacts with the light switch and calls a Server event on the ThirdPersonCharacter Blueprint, which calls a multicast. I have tried playing around with this, calling Run on Server from Multicast, I have tried it with and without Repnotify, but while the Client will replicate the lightswitch changes to the Server, it still won’t replicate the changes in the Switch Rotation variable’s value, which causes some issues. And yes, both the Light Switch object and the Switch Rotation variables are set to Replicate. I’m lost here.

It seems that your LightServer function directly invokes the LightClient multicast function without locally applying any server side state changes (rotation on the server) - the final effect is that even if you pass the rotation as Multicast client function, and the client eventually receives the rotation value, but this value is only set on the client side - the server rotation value doesn’t ever get updated - so even if you saw the client version rotation got changed, the server rotation remained unchanged.

I would suggest that your LightServer function contains the logic to update the server rotation of the Light, and if the LightActor/Rotation are properly marked for replication, you don’t have to invoke the multicast LightClient function anymore - just let the replication sort out the rest.

That didn’t work, result is the same. I think I’ve tried every possible combination of Multicast/Run on Server set ups, it either breaks the switch even more, or the result is the same as now.

These are the values after I interact with the Switch from the Server:

And this is after I do it from the Client:

I put a breakpoint on the Run on Server and Multicast functions, the Rotation variable’s value is always the correct one, but somehow it doesn’t apply on the Server side.