Health bar returns 100 even though Humanoid's health is somewhere between 99-1, returns 0 correctly

  1. What do you want to achieve?
    I want to make the player’s health appear above their Head.

  2. What is the issue?
    The script always returns 100, not 99-1, but does return 0

  3. What solutions have you tried so far?
    I have tried:
    I. Getting the Player’s Health from a variable.
    II. Getting the Player’s Health from script.Parent:WaitForChild(“Humanoid”)

Code:

local health = script.Parent:WaitForChild("Humanoid").Health -- This variable is
-- in a loop so it should be updating, but it only updates when the player has
-- 100 or 0 health.
print(health) -- This is returning only 100 or 0 for some reason.
newgui.GreenBar.Size = UDim2.new(0, health, 0, 10) -- Health bar frame, only
-- updates if the Player's Health is at 100 or 0.

Any help would be greatly appreciated.

How are you damaging/changing the players health?

1 Like

Alright, yep, you just solved my problem, thanks. I forgot I was changing from the client, sorry about that.

1 Like