Simple networking replicating variables doesnt work

Hey Folks,

I have a question about networking replication.

When the game starts the game mode should run an event, which is sending variables values to all player controllers. After that the widget blueprint should show the currrent values. But only the server gets the correct settings, the client always shows " 0 ".

I uploaded three screenshots to show you what me problem is.

If you have any ideas or solutions feel free to answer.

Best wishes,

First of all doing a Multicast on the GameMode is not going to work for the clients since GameMode only exist on the server.

The PlayerController is not a good place to keep information that other players might need since clients only know about their own PlayerController.

GameState or PlayerState is a better place to keep this type of information since they are replicated to all clients. Use GameState if it is common to all players and PlayerState if each player could have different values e.g.

Another good place to keep values for all players to see is on the Pawn/Character.

Widgets only exist locally and can’t replicate anything.

@**GarnerP57 **Thank you for your help!

So far I managed to get it to work properly, but I’m a bit concerned about cheating.
I located the Variable on the character BP. Isnt it vulnerable since the variable is located on the Client?

I always thought that all important stuff ( like player health ) needs to be kept save on the server, to prevent clients from manipulating.

It is true that clients can overwrite replicated with custom values, aka try to cheat.
But for the server the values will still be as they were, and as soon as the server changes values for replicated variables these new values get replicated to the client.

If a player has his health status set to 100 via replication, and then tries to cheat and changes his health to 9999 locally it won’t do the cheater any good, the server won’t notice that change and still keeps the health at 100 and as soon as his health drops by 1 the server will replicate the new health value 99 to all clients and the cheater will gets his 9999 cheat-heatlth overwritten by a 99…
The important part is to keep the important logic (taking damage, telling people that someone died, etc) on the server.
Never let the client do hit- or damage calculations, let the server do it and let the server via replicated values and RPCs tell clients whether they hit something or not.

In your case, just make Health a replicated variable in the character.
When a player logs in he’ll automatically get the current up-to-date value for it, no need for RPC calls.
In fact, you can make your replicated variable be a RepNotify-Value, so whenever it gets update it calls the RepNotify-Function for that value. In that function you can get PlayerController index 0 (which is the current clients player), get his hud and call functions to update the widgets with the newly recieved health value.