Client HUD not showing correct values

So I’ve been scratching my head over this all day today and can’t seem to get anywhere. Essentially, I just want to print the Health and ammo for each player on their HUD. The server displays these values correctly, but the client does not.

To begin, both the ammo and health values in the Character C++ file are marked Transient and Replicated.
For dealing damage, I’m overriding the Actor::TakeDamage function in my character class, and here’s where a lot of my doubts start to creep in. In the function declaration, I haven’t marked it as replicated or on server or anything. If I try to do that, I get a compilation error that functions with a return type can’t be replicated. Inside the function I do a HasAuthority() check (another doubt - when am I really supposed to use this? Does it only make sense on functions executed on the server? or RPC/multicast functions? What’s the deal?).

If I start two instances in the editor,
ON THE SERVER : Both the server and the client deal damage and take damage. Updated Health and Ammo values are shown
ON THE CLIENT : Both the server and client always have the default health and ammo values. Updated Health and Ammo values do not reflect.

Any suggestions or discussion would be greatly appreciated. Thanks!

I would just put the health and ammo values in the PlayerState that belongs to the PlayerController, and set those variables to replicated. If the HUD needs to instantly update instead of waiting for relevance or a repnotify, then use multicast to force update.

I did that and it works perfectly. Can’t believe I couldn’t think of that myself. Thanks for the help! :slight_smile:

I’m glad it helped you. Please mark my answer as Accepted so others with the same problem can find it more easily.