wait(.5)
game:GetService("StarterGui"):SetCoreGuiEnabled("Health", false)
plr = game.Players.LocalPlayer
chr = plr.Character
hum = chr.Humanoid
sp = script.Parent
bar = sp.Bar
hbar = bar.Health
while wait(.001) do
hbar.Size = UDim2.new(hum.Health/hum.MaxHealth - 0.368, 0, 0, 35)
if hum.Health<=20 then
hbar.BackgroundColor3=Color3.new(255/255, 0, 0)
else hbar.BackgroundColor3=Color3.new(0, 255/255, 0)
end
end
hubar = bar.Hunger
This local script controls the health bar, This is the layout:
It works well but the length of the healthbar isnt equal to my health. Like whenever my health is 10 the healthbar falls into negative numbers and looks like this:
How do I stop this from happening? (the original length of the health bar is {0, 700},{0, 35})

8 comments
Is there anything in the output?
Nothing
It's because of the scale value, you're subtracting .368 from the scale which when your health reaches 36.8 will start the scale being a negative value, thus providing you with your current result.
So what should it be?
I would recommend that if using scale values for health bars, that they be between 0 and 1, which the Health/MaxHealth will provide.
Mind putting that in an answer for me?
You've asked this question before.
I dont believe I have.