Node returns None when reading on client

Here’s the deal. When I spawn a HUD element, it works on both the client and the server. However, when I call the function OnHealthChanged, it only works on the server, while the client doesn’t update its UI.

Here’s the PlayerController:

Here’s the function that tries to access it:

Here’s the error I get:

Thanks in advance.

You’re working with multiplayer where the rule says “Server da master”

Create a Custom Event and select it to run on Server

And run this event instead when you run OnHealthChanged

This will ask the server to do the job

What you try to do now is ask Client to perform the code but that’s not allowed - you have to ask the Server to do the job for you

I am not so well in MP so you may want to wait for some better answer about how it should be replicated correctly

I see. however, the code is not meant to change the HP itself, but rather just change what the UI displays. would I still need to do that on the server?

As far as I know (and understand MP) - you need OnRep Variable (when you set a variable to be OnRep it creates a Function for you)

So your HP Variable should be OnRep and every time this value changes the responsible Function will be called

Make the Function to edit HUD

if that fails - add a Custom Event (Owning Client) that will handle HUD Update and call this Event from the Function

I tried doing this but now it won’t function either on the server or the client.

gentle bump

Can you shed a little more light as to if the HUD should be seen by everyone or just the client?

Of course. Every client is supposed to have their HP bar on the top left as seen on the image. when the health is changed, the BP_OnHealthChanged event is triggered and this lets the player know their current HP

Perfect. I think your setup approach is fine. Do you have it set to “Run on Owning Client” for the Event?

this is the specifier of BP_OnHealth_Changed

while ChangeHUD executes on Owning client

This was a amassive oversight on my part. I had tried to cast the HUD screen directly to the health widget, rather than getting the Health widget from the HUD screen.

1 Like

I believe you are jsut using the wrong specifier. I think you want Client? Seems like blueprint authority only runs on the server.

1 Like