Health Bar Not Working Properly

I was working on a health bar last night and it will not work properly. If I were to put it over my head and reset, it would work. However, when I would take damage from another player, or a damage brick, it wouldn’t affect the health bar nor would it show to the other player, yet I would still take the damage.

I got help with a script to make it to where the local player doesn’t see the health bar above their head, but others still can. Yet the same issue still occurs.

Any help would be greatly appreciated.

Health Bar

How it is in StarterCharacterScripts
image

The Script

If I put print in the main part of the script, it properly prints.

print(“Health changed!”)

However, it doesn’t do what it’s main purpose is.

The local script doesn’t really matter in this situation as it’s just a local script to disable the Billboard Gui for the local player, so no need to post a screenshot.

Thanks!

You’re changing all the sizes to 0 other than the X Scale.
Try selecting the Meter and see if it’s size actually changes in the properties.
Otherwise I don’t know what could be causing this problem.

Just did than and it worked!
However, I have an issue where it take a second or two for it to register the health. It won’t move until it finishes moving down. Any idea how to fix this? I want it to practically be real time. Where if you’re damaged again right after the first time, it drops to the correct health instead of freezing for a second.
( it mainly just does this at the last section of health

If you want it to be instant you can just do Meter.Size or just change the last argument in the TweenSize to be less than 1 second.

1 Like

Works perfectly now, thank you!

1 Like

The tween size function takes in a parameter as “override” ,a bool value, which indicates
“Whether the tween will override an in-progress tween” and it is the fourth argument of the function.
So it will look somewhat like this:
healthGui.Heath.Meter:TweenSize(UDim2.new(healthchange,0,0,0),“In”, “Linear” , true , 1).
now it should not pause and it should drop or rise to the exact health at that time.

1 Like

Awesome, thank you! I’ll definitely try this out