How to set up correct Widgets for multiplayer?

Hi! I’m currently working on a multiplayer game and I’ve tried to setup a widget with a health bar. Everything works correctly when I launch the game in a new editor window both on the client and on the server until the respawn happens. (Player dies, I press a button to respawn the player at a location of a PlayerStart) For some reasons the widget does not initialize.

I think I messed up the Widget Blueprint, especially the casting part, because after the respawn I get tons of error messages about failed casting.

Here is the custom made player controller that creates the widget and then adds it to the viewport.

Lastly, the simple setup for the health bar.

I hope some can help me. I’m lokking forward for the replies. :slight_smile:

It would help if you show the code of the “RespawnPlayer” function.

Have you checked if the health bar work correctly on both sides? When you get an “Accessed None” error, from the “Add to Viewport” function you need to check if the player controller is a “Local Player Controller”, otherwise the “Create Widget” function will return None for every client.

Then you can leave out the “Switch has Authority” and “Is GameMode Valid” nodes, because the “Request Respawn” function will only be executed on the server.

Instead of having a “Character” variable in your main widget, you can use the, “Get Player Pawn” function, the player controller at index 0 is always the locally controlled one, this way you can make sure there is nothing wrong during initialization.

Hi! Thank you for your reply, with your help the widget works as I wanted. Thank you so much.