Health script not working correctly

Hi, i’m trying to do a Health Display GUI, but when the life goes 90, she just desappear.
There’s a way for fix that?

I’m quite new on scripting, like not that new, but yeah, i am.

There’s the script

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local frame = script.Parent

humanoid.HealthChanged:Connect(function()
	local percanage = humanoid.Health / humanoid.MaxHealth
	if (percanage >= 0) then
		frame:TweenSize(UDim2.fromScale(percanage, frame.Size.X.Scale))
		print(percanage)
	end
	frame.Label.TextColor3 = Color3.fromHSV(0, 1, 1)
	wait(0.1)
	frame.Label.TextColor3 = Color3.fromHSV(0, 0, 1)
	frame.Label.Text = math.floor(percanage * 100)
end)

Thank you.

did you do this script on a server script or a local script because i think this script should be on a local script

this is an localscript, not an server script.

That’s your problem health script should be in a ServerScript named “Health” and put into “StarterCharacterScripts”.

I dont think so, cause the script works fine, but sometimes, when the health goes to 90, just desappear the image.

like that:
image

Oh my apologies, I didn’t realize your problem was with a GUI, and not an actual health script.

I’m not good with arithmetics but “local percanage = humanoid.Health / humanoid.MaxHealth”
shouldn’t that be “local percanage = humanoid.Health / 100”

also you are just giving yourself a hard time by with this part
“frame.Label.Text = math.floor(percanage * 100)”
instead why don’t you just use
“frame.Label.Text = humanoid.Health”
I’m just reading trough it quickly so sorry if I missed something.