Want to replicate a string to UMG

This is my first time integrating network to my project, and I’m running into an issue.What I want to do is that when both the server and client are connected, I want the server to enter a string (via umg) and then replicate it to the umg of the client, The client successfully joins the server, but using custom events nothing happens.

This is the controller. Ive tried using multicast and run on client but neither works

This is the game instance. This node is executed when the host enter the number of player or if a new player joins.
The number of players value only changes on the server and not on the client.
Can anyone help with this? Thank you.

The main issue here is the use of the GameInstance. The GameInstance does not replicate. Each player will have its own GameInstance and be unable to see updates from the others. To fix this, simply put the “Number of Players” variable in GameState.

If that alone does not fix your issue, try switching away from a custom event and just binding the value of “Notification Text” to “Number of Players” inside of the widget (see below). That way, any time the server updates “Number of Players”, all the clients will automatically show the new value. Just be sure “Number of Players” is marked as Replicated.

Let me know how it goes!

Im trying it in the gamestate. The value updates when the server updates it but not the clients, also How can I update all clients and server so that it displays a new value everytime a player has joined? Thank you for your help

To have it update on the clients, make sure the variable is set to “Replicated”.

For your second question, which part are you having trouble with, detecting that a player has joined or displaying the new value immediately? If the issue is detecting when a player has joined, just use the OnPostLogin event inside the GameMode. Just have it cast to the GameState in order to set the value of “Number of Players”. Then as long as you used the Bind option in the widget to set “Notification Text” to equal “Number of Players”, you should be golden.

The value is set to replicated but for some reason it does not work when someone other than the server changes it.

Sorry for the delay. I believe any changes to GameState’s variables need to be done by the server, so depending on how you have it set up, you’d need to find a way to execute the action on the server. For example, if the value is changed by a client’s widget you’d need to have the widget tell the player controller to execute a custom event in GameState that is set to “Run on Server”.