Replication works on client, not on server

Hey there!
I have a rather annoying issue. We’re changing a variable on all players(multicast) and spawning in an fx(also multicast). Now this gets triggered through UMG, you press a button and then you cast to your characterBP and it runs on server and lets it run on all clients. Which works perfectly!

Now the issue is, if we do this on a client, the client presses the button on UMG then it happens on all clients and server, the variable change and the fx spawn. If the server does this, the fx spawns on all clients but the variable doesn’t change, not even on the server. Why would that ever be? if it spawns the fx it should also change the variable.

Now the way we’re retrieving the variable is through level bluerint, level blueprints gets all actors of class(characterbp), and based on the variable do X.
Can someone tell me what i’m doing wrong? I can’t find the logic as to why it’s failing. Except that we’re retrieving the variables wrong in the level blueprint but i don’t see another way of doing it.

Here are the images: In the Character BP: [FONT=Helvetica Neue]


In the Level BP: [FONT=Helvetica Neue]


Am i doing something wrong?

Kind regards,
Celeste[FONT=Helvetica Neue]

First thing that i see is, that you are setting the Variable too often.

You only need to do this at 2 points.

  1. TravelStart after the Authority Exec.
  2. TravelStart_Rep also after its Authority Exec.

Then your Multicast doesn’t need the ID as Parameter. The Variable is replicated. Setting it on the Server
will replicate it to the Clients anyway.

And you don’t need the “SwitchHasAuthority” in “TravelStart_Rep” since it is “RunOnServer”. It won’t run on a
client. You could leave to be sure that this is really only executed on the Server.

If you’ve cleaned it up, check if it is working. If not, come back and post the updated pictures (:

Okay so this works kinda better.

The client can update both server and client, with the multicast spawn emitter.

Now the server can update the client variable, but it won’t spawn the emitter. Also the server can’t update it’s own variable, so on the server the variable doesn’t change, but it does on the clients.


For the emitter part, you simply forgot to place the Multicast to the “TravelStart” Authority Output. It is only changing the variable.
For the part with the Variable -> This is really weird. If the Server updates the variable for the clients, i MUST update it for himself.
That’s how the replication system works. Server sets replicated variable -> clients get the same value (which might take time cause of
higher pings).

When and where do you check the ServerSide value?

“When and where do you check the ServerSide value?”

By this i guess you mean where do i retrieve and check the variables?
Well the level blueprint checks for all actors of class(the character bp) every x seconds, and based on that adjust something in the map. So if it doesn’t change it in the map i know it’s not having the updated value. Maybe i’m just retrieving the values wrong?

You can see how i’m retrieving them in the second image on the start of the thread.
I also tried to cast to bp base character with input get player pawn, but then if the client changes the variable, it changes on server, not client. If server changes the variable it changes on client, not server.

So i’m really not sure why it’s doing that.

Oh, i guess i know what is wrong. That’s an error at my end sorry.

You want that number to be changed for ALL Players right? Not only the one you are working in.

PS: I will a small picture with how you can fix that. Would be too complicated to explain this with words.

Yea it needs to change to everyone. And thanks!

Ok, so do you know about the PlayerState class? As the Name tells, it should keep track of the Player’s State. There is also a Class called “GameState”.
Which is the same for the current Game. We/I will use this here, because of one simple fact: It is easy to access and replicated!

The basic GameState class has an Array called “PlayerArray” with all PlayerStates. Clients and the Server can access it. So instead of creating the
Variable “CurrentMapID” in the Character, we will move it into our own PlayerState class.

You can create a PlayerState class like you create all other Blueprints. You just need to search in the All Classes menu for “PlayerState” when creating
a Blueprint:

“MyPlayerState” is the one i already created for your setup. So you may want to do the same and select “PlayerState”.

The PlayerState class can be set as the default one to use in the GameMode. Sadly this is not doable over the “Maps and Nodes” Settings
of your Project. You need to open your GameMode and select the ClassDefaults. There you will find list of Classes, like Pawn, Controller,… and also
PlayerState and GameState. We want to change the PlayerState here:

Now in the PlayerState, create your Variable “CurrentMapID” and make it replicated.

Back to the CharacterBlueprint, you do this:

Note: The Multicast is called on all Instances of this Player. For this example i spawned an explosion on the Actors location. This means the Explosion
will happen in the location of this Character on all clients. It doesn’t mean that every Character will have the explosion at his AND the others location.

If you need the emitter to happen on all Characters, so that every Character would have an explosion and not only the one calling it, you need
a different setup, but i can’t see what exactly your Emitter should do, so i assume this is correct.

Oh this works! Thank you for that! I completely forgot about using player states.