How to replicate from Client to Server

Have a look at this answer: Run on server doesn't get triggered on Actor Blueprint - Blueprint - Epic Developer Community Forums

In your case the game state is not owned by the client.
You can use the client player state to send a request to the server player state and then forward to the game state.

Hey guys,

Hope someone can help me as i am despairing right now, fiddling around with variable replication :>
I have no problems when doing something on the Server. The variable gets replicated just fine on my Clients but i just can’t figure out how to get the variable replicated when calling a function from the client…

In my PlayerState class i have set the replicated variable:

UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)

int32 test;

In my GameState class i have set the function that is called at some point in the program and changes my test variable:

UFUNCTION(BlueprintCallable, Category = “GameMode”, Server, WithValidation, Reliable)

void swap();

Now from my understanding thus far, what i would expect is that when the function gets called from the Client it gets executed on the Server instead. But nothing happens, just nothing.

As said above it works fine when the Server calls the function and reading through similar questions did not help my understanding much either :confused:

All help is appreciated, thanks in advance :slight_smile:

ty, i will try that and report back :slight_smile:

yay, it worked !
So many hours got lost on this, thanks so much mate !