Does OnRep Notify work on the server when called from a client?

Hello, I’m having a small problem with OnRep Notify.
When I set a variable from the server, everything works, and the function is called on both the server and the clients. However, when I set the variable value from a client, the server doesn’t seem to get the OnRepNotify function call.
Is it supposed to happen or am I missing something?
you

If I’m not mistaken, OnRep Notify is only triggered on the clients. Do you mind showing how you replicate your variables?

you for your quick answer!
I think I read on the documentation that onRep Notify is called both on the server and the clients. Anyways yes, this is how i replicated it for the test

Again here, when i press q from the server everything works, while if i do that from the client, only the client is notified
you!

Assuming you are trying to replicated a variable on a PlayerController, a Pawn or a Character (or any other actor owned by a player), here is a setup you can use:

What is essential to understand is that a replicated variable will be replicated down to the clients only if it is changed on the server.

Now, some explanations of what happens :

  • On the server : This is basically your current setup. When Q is pressed, the value of ‘Status’ is changed and as we are on the server, it is replicated to the clients.
  • On a client : When Q is pressed, the value of ‘Status’ is first locally changed on the current client. Then if we don’t have the authority over the actor (which is the case because we’re not on the server), we are going to call the custom event ‘Server Set Status’, which will only execute on the server. This function will change the value of ‘Status’ on the server and as explained above, it will automatically be replicated to the other clients.

N.B. : Note that I selected Skip Owner as the Replication Condition (right panel) because with this setup we take care of changing the value on the owner before replicating it.

Hope it helps.

1 Like

That’s exactly what I was looking for, you so much for your help!