Change variable in client, want server to see it but not clients

Is there any way that an actor can notify the server of a variable change on the actor but hide that variable change on other clients?

It is my understanding that if a variable changes and it is replicated, all other clients will receive the updated variable. For security purposes I do not want this to happen.

Hi there, true, no one wants this to happen. That is why clients are not even allowed to send data to other clients :slight_smile:

Only the server can replicate variables or multicast events to all clients.
There is only one way for the client to communicate to the server:

Create an Event where you set Replication to “Run on Server”. If you call this within your blueprint, only the server executes the event. (In the background it gets sent over network or just executes if it is already the server.)
So now you need a Blueprint that both Client and Server have. PlayerController fits the best in most cases.

Hope that helps :slight_smile: Marooney

I have tried several times but it does not seem to work. I should note that the actor is not possessed by my controller. Think of a strategy game where you need to adjust a variable in your unit but keep it secret on the for the rest of the clients. The server that does the calculations knows about its updated state but not other clients

I just moved the event to my playercontroller but it does not work still

UPDATE: I moved it to the pawn attached to the controller since I needed to use some variables attached to the pawn that are replicated. My issue now is that the “Run on server” runs on the proper pawn (verified by self reference print string) but the variables that pawn has are not replicated. This producing an error.

I’ve made some progress. The Run on server now works exactly as you specified through the controller pawn.

Great :slight_smile: Perhaps you want to check out this tutorial to understand all of the replication features :slight_smile: You will need them anyway :slight_smile: