Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my health bar stuck at full bar after several death?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Human = Character:WaitForChild("Humanoid")
local HealthFrame = script.Parent

Human.HealthChanged:Connect(function(Health)
	HealthFrame.Size = UDim2.new(Health/Human.MaxHealth,0,1,0)
end)

1 answer

✓ Accepted answer

Try connecting your HealthChanged event to CharacterAdded event:

Player.CharacterAdded:connect(function(character)
	local Human = character:WaitForChild('Humanoid')
	Human.HealthChanged:Connect(function(Health)
		HealthFrame.Size = UDim2.new(Health/Human.MaxHealth,0,1,0)
	end
end)

After placing this code, you won't need your Character variable (line 2) and Human (line 3).

1 comment

0

Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.