Health script not working

Im not sure whats wrong with this script, please help me

indicatorText.Text = char:WaitForChild("Humanoid").Health.."/"..char:WaitForChild("Humanoid").MaxHealth

Please specify the issue that is going on with that line

There’s nothing wrong with that snippet, as far as I can tell, but is this the entire script? You need to elaborate on what, specifically, is not working with this.

I assume that it’s always showing 100/100 or whatever you have the default MaxHealth set to?

If so, you need to make an event listener to update the text when the Player’s health changes:

local human = char:WaitForChild("Humanoid")
human.HealthChanged:Connect(function(curHealth)
    indicatorText.Text = math.floor(curHealth) .. "/" .. human.MaxHealth
end)
1 Like

Oh sorry for the trouble i had to put that out of the event

Nothing seems to be wrong with that code. It appears that you’re trying to make a health indicator. If you are going to reference an object multiple times then it’s best to use a variable to reference it. Something like this:

local Humanoid = char:WaitForChild("Humanoid")
indicatorText.Text = (Humanoid.Health .. "/" .. Humanoid.MaxHealth)