Essentially my healthbar goes 1 pixel off when I set my health back to 100. I just do: health = 50 resizes to 101 health = 100 resizes to 199
What the heck?
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false) local plr = game.Players.LocalPlayer local rs = game:GetService("RunService").RenderStepped local quad = Enum.EasingStyle.Quad local out = Enum.EasingDirection.Out while plr.Character.Humanoid.Health >= 0 do local health = plr.Character.Humanoid.Health if plr.Character:FindFirstChild("Health") then plr.Character.Health:Destroy() end script.Parent.Background.Health:TweenSize(UDim2.new(0,health*2,0,5),out,quad,0.4,true) wait(0.1) end
I tried using math.ceil/math.floor to fix the problem but it did absolutely nothing.
I rewrote your script, I'll tell you everything I did:
--LocalScript function callback() --this is the callback return end game:GetService("StarterGui"):SetCoreGuiEnabled("Health", false) local plyr = game:GetService("Players").LocalPlayer plyr.CharacterAdded:connect(function(char) local h = char:WaitForChild("Humanoid") --get player,then character, then humanoid. h.HealthChanged:connect(function(health) --instead of loop script.Parent.Background.Health:TweenSize(UDim2.new(0,(h.MaxHealth/health)*20,0,5),"Out", "Quad", 1, true, callback()) --replace nil with a function --MaxHealth/health end) end)
Hope it helps!