local HealthBar = script.Parent:WaitForChild("HealthBar")
local bar = HealthBar:WaitForChild("GreenFrame")
local hpText = HealthBar:WaitForChild("HealthStatus")
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local connection_health
local connection_max_health
local character = player.Character
local function update()
local humanoid = character:WaitForChild("Humanoid")
bar:TweenSize(UDim2.new(humanoid.Health / humanoid.MaxHealth, 0, 1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quint, .1, true)
hpText.Text = math.ceil(humanoid.Health)
end
local function setConnections()
local humanoid = character:WaitForChild("Humanoid")
connection_health = humanoid:GetPropertyChangedSignal("Health"):Connect(update)
connection_max_health = humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(update)
update()
end
player.CharacterAdded:Connect(function(char)
character = char
if connection_health then connection_health:Disconnect() end
if connection_max_health then connection_max_health:Disconnect() end
setConnections()
end)
setConnections()
I think it is getting stuck cause’ you are not updating the character after the hum dies.
Try disabling ResetOnSpawn property on the ScreenGui and add this to ur script
humanoid.Died:Connect(function()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
end)
and if that doesn’t work then try
while true do
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
wait(.01)
end
and if that doesn’t work either try just maybe setting ResetOnSpawn property to true on the ScreenGui
or maybe ur entire original script is just not working