Currently when you die in-game with this health bar then it will not reset and can't figure out how to reset it.
HealthHandler (Local Script)
local bar = script.Parent.Bar local healthBar = script.Parent.Health local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local colorGreen = Color3.fromRGB(0, 255, 17) local colorRed = Color3.fromRGB(255, 0, 0) local tweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut) local goal = {} goal.Size = nil goal.ImageColor3 = nil while wait() do if not char:FindFirstChild("Humanoid") then return end local health = char.Humanoid.Health local maxHealth = char.Humanoid.MaxHealth goal.Size = UDim2.new(bar.Size.X.Scale / maxHealth * health, 0, healthBar.Size.Y.Scale, 0) goal.ImageColor3 = colorRed:lerp(colorGreen, health / maxHealth) local tween = tweenService:Create(healthBar, tweenInfo, goal) tween:Play() tween.Completed:Wait() tween:Destroy() end
just change the char variable whenever the character respawns
local bar = script.Parent.Bar local healthBar = script.Parent.Health local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local colorGreen = Color3.fromRGB(0, 255, 17) local colorRed = Color3.fromRGB(255, 0, 0) local tweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut) local goal = {} goal.Size = nil goal.ImageColor3 = nil plr.CharacterAdded:Connect(function(newchar) char = newchar end) while wait() do if not char:FindFirstChild("Humanoid") then return end local health = char.Humanoid.Health local maxHealth = char.Humanoid.MaxHealth goal.Size = UDim2.new(bar.Size.X.Scale / maxHealth * health, 0, healthBar.Size.Y.Scale, 0) goal.ImageColor3 = colorRed:lerp(colorGreen, health / maxHealth) local tween = tweenService:Create(healthBar, tweenInfo, goal) tween:Play() tween.Completed:Wait() tween:Destroy() end