local function updatehealth()
local health = humanoid.Health / humanoid.MaxHealth --Maths
--local info = TweenInfo.new(humanoid.Health / humanoid.MaxHealth,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0) --Tween Info
--TW:Create(gui.Health.HealthBar,info,{Size = UDim2.fromScale(health, gui.Health.HealthBar.Size.Y.Scale)}):Play() -- Create The Tween Then Play It
gui.Health.HealthBar:TweenSize((UDim2.new(health,0,gui.Health.HealthBar.Size.Y.Scale,0)),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.5)
gui.ActualText.HP.Text = math.floor(humanoid.Health)
end
For some ungodly reason i cant seem to get my health bar to accurately work:
When not clamping my health values, it stays out of the confined space i want it i
when i clamp its values to stay in said box, it does not track properly
local health = math.clamp(humanoid.Health / humanoid.MaxHealth, 0, 0.737)
For reference it should look like this:
When i clamp the values, it accurately shows my health at 100% but once i set my huamnoids hp to 50 the bar stays at around 75% rather than accurately showing it at 50%