This is my healthbar's script
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local healthbar = script.Parent.Frame:WaitForChild("HealthBar")
game:GetService("RunService").RenderStepped:Connect(function()
local humanoid = char:FindFirstChild("Humanoid")
healthbar.Health.Size = UDim2.new(humanoid.Health/humanoid.MaxHealth,0,1,0)
end)
When you load in everything is fine but when the player gains more health the gui goes off the screen and the only way i found to fix this is by resetting. When you reset the gui works perfectly.
So what do i have to do to make the gui work as the player gains strength without having to reset

1 comment
instead of using an if statement i would just use math.min().