How would I do this?

Hi, I wanted to make a boss health bar where it has a red bar and a orange bar. If you’v seen some videos of peoples fighting bosses in Ultrakill, you can notice that if the player keeps hitting the boss over and over, the orange bar stays put until the combo is over in which it aligns with the red bar.

I wanted to do the same but how would I do it? I used coroutine to start off but I’m kind of lost.

I know the topic sounds confusing but I’ll simplify it if you want me to.

Some coding I made just to test.

local orangehp = script.Parent.Frame.OrangeHP
local redhp = orangehp.Parent.RedHP
local bosshumanoid : Humanoid = script.Parent.BossHumanoid.Value
local ts = game:GetService("TweenService")
local loaded = false

local co = coroutine.create(function()
	loaded = true
	task.wait(1)
	ts:Create(orangehp, TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.fromScale(bosshumanoid.Health/bosshumanoid.MaxHealth, 1)}):Play()
end)

local function healthdrop()
	ts:Create(redhp, TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.fromScale(bosshumanoid.Health/bosshumanoid.MaxHealth, 1)}):Play()
	coroutine.resume(co)
end

bosshumanoid.HealthChanged:Connect(healthdrop)

This is incomplete so I’m just reaching out.

Make both will decrease or increase in the same way. If you combo the boss then just decrease the health bar and don’t decrease or increase the orange bar. If boss hits you make the orange and health bar in same position. If you want more complicated thing then tell me.

I highly recommend runservice for this,
because tweening for values that are constantly cahnging doesn’t work so well

local Runservice=game:GetService('RunService')
local CurrentOrangeThing=100
Runservice:BindToRenderStep('HealthbarAnimation',0,function(dt)
	CurrentOrangeThing=math.max(CurrentOrangeThing-dt*DecreaseMultiplyer,bossHealth)
	OrangeBar.Size=UDim2.fromScale(CurrentOrangeThing/bosshumanoid.MaxHealth, 1)
end)

This is without the beginning thing
If you are wondering why I deleted my other post is because I accidentally pressed ctrl+enter