"Run on Server" not replicating from client to server

Hello, I’ve been banging my head against the wall here for a week or so trying to understand the multiplayer functionality and a constant roadblock has been trying to get the client to send any information at all to the server. I’ve gotten the client to respond to replication from the server fine.

I’ve been testing all this out with just an enum value, and no matter the implementation the client never sends information.
I’ve tried using “Run on Server” Replicate events which doesn’t work, even though the documentation says this is how clients send info. Could someone explain how to send an enum value from a client to a server? I’ve found nothing directly helpful online about this.

Firstly Client’s can only do “Run On Server” events while they own the Actor the event reside on.
The client always own a PlayerController and their PlayerState. They also own the Pawn/Character that they may possess.
Ownership is inherited so if the Character owns an Actor (use SetOwner on the Server) then the client also become the owner of that Actor.

Secondly you need to wait for the ownership to be updated on the client before attempting to call the event. If you are calling the function too early then you will see this warning in the log

… No owning connection for actor [Actor]. Function [Func Name] will not be processed…

The best way to ensure that the server already made the client the owner is to override the OnRep_Owner function in C++ otherwise you can have the server set a RepNotify variable with Replication Condition = Owner Only. By the time this variable is replicated to the owner it is safe for the owner to call the RunOnServer event.

1 Like

Thank you for the reply, figured out how to do it correctly - I was trying to call events from a GameState client-side to server-side via Run on Server, but GameState is only copied to clients not owned by them (unlike GameMode which is server-side only and not replicated). So had to move the events to the client-owned PlayerState which calls the server which replicates the changes across the network.