Blueprint Networking - Lobby Widget Can't get variable replication right

Hi, I’d need help with setting up a lobby widget, where the server has the option to change some settings and the client gets these changes on his screen as well (like server selects a different map, so client updates the “selected map” text field respectively). I managed to get the button visibility system working, so I can decide which buttons I hide for the client when the widget is spawned. My problem is displaying the server’s version of a variable to the client. In this concrete case I am trying to show the name of the players in the lobby.


Here is how I approached it, and it is not working.

In myPlayerState, I created two replicated variables: ‘Host Player Name’ and ‘Client Player Name’. Upon Event Begin Play, I set two timers to run a Custom Event each second, depending on the authority of the player. If he has authority, I execute a Multicast Event named ‘Refreshing Host Name’, and I set the ‘Host Player Name’ to the name of the player (from the built in ‘Player Name’ variable). If he is a client, I execute a Run On Server Event, and I set the ‘Client Player Name’ to the name of the player.


In myPlayerController (the ‘Master Lobby Widget’ is spawned from here) I run a function called ‘Update Player Names’ each second. In the function, I cast to myPlayerState and I update the host and a client name fields in the widget with the value of ‘Host Player Name’ and ‘Client Player Name’.

The result is that the server only shows his own name, no matter if he is alone, or the client is connected, and the client shows his own name for both the host and client player name slots, which is quite confusing for me.

Any help regarding this would be really appreciated.


I would of had the wanted variables held in the server version of the game instance possibly. Then in the bp that activates the ui and is attached to the player (like player controller) get game instance case to it and grab those variables into the server version of the player controller replicated. Then in the ui I would bund the text element that will hold the displayed value and in the bind get controller and use the variables in the controller as the output in the return node.

You could even make use of rep notify to cut down on cycles and have code run only if it changes.

Thank you for the answer, I will try out the suggested solutions as soon as I can. However, may I ask what difference it makes if I create the variables in the Game Instance, instead of the Player State? In my understanding, one Game Instance exists on all players machine, and every player’s Player State exists on all clients and the server. Is this assumption right?

What do you mean by this? How could I achieve that, there is no Switch Has Authority in Game Instance.

[EDIT] I have a few more questions. Basically you say, that I should create and give value to the Host and Client Name variables in the GameInstance, and then from PlayerController I should CastTo GameInstance and get those variables. Do you mean assign their values to new variables? Because if no, how could I Cast To Player Controller and get the name variables from the Widget bind if they are not actually stored in there? If yes, why I need to do this extra step, why can’t I CastTo GameInstance from the Widget without involving PlayerController?

Sorry if the answers are obvious, but I got really confused now.


i think im a bit confused on what you are trying to accomplish perhaps. You likely have some form of replication issue. I use a bit of a wierd hacky type system for my multiplayer chat. Because UI cant see server and server cant see UI i have to pass variables around a tiny bit to get them from player to server then out to all players. Im thinking its KIND OF like what you are doing. i use the game instance and teh game state depending what im trying to accomplish.

  • server has a player name for its hosted lobby.

  • it sends its name to a replicated variable in the GameState (might have to set the variables to rep notify and then run a multicast event with an input for the variable and a set on the other side)

  • player then gets GameState and plucks that variable for server owners name.

  • i would then from the server get all actors of class on whatever loop you want. Find all the player controllers with a name variable that would ne set in them from wherever you set it.

  • then add those names to either an array or a string or however you want to do it and save that to a replicated variable to be grabbed from the player UI.

Thank you very much Vindomire for your help, sorry for getting back late, but I had other issues with more priority to resolve first. After getting a little bit more familiar with networking I managed to resolve the issue by rebulding the whole system. Thanks again for your suggestions!