local bar = script.Parent
local player = game:GetService("Players").LocalPlayer
local humanoid = (player.Character or player.CharacterAdded:Wait()):WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function()
local hp = math.clamp(humanoid.Health/humanoid.MaxHealth,0,1)
game:GetService("TweenService"):Create(bar, TweenInfo.new(0.1, Enum.EasingStyle.Quad),
{
Size = UDim2.new(math.clamp(hp,0,1),0,1,0),
BackgroundColor3 = Color3.fromHSV(hp/3,1,1),
}
):Play()
end)
The frame in the frame is the same size and it’s green (0,255,0)
It also takes care of itself … after it’s called.
lerp is also cool … that works perfectly btw … and runs itself, what more could you want …
Set it and forget it. What if they get hit 6 times in a row … lerp is going to mess that up.
This is just a different way to change the color. Not an entire generic code that runs everything automatically. The code is a tween if you wanted slower moving so it looks like it’s falling down and not just updating all you needed to do was add to the tween time …
TweenInfo.new(0.5, Enum.EasingStyle.Quad) looks really good. I’ve always found lerp to be a bit jerky. But I’m pretty picky. I also assumed you understood how to use tween. “no but i want it to slowly change”