Hey guys, So I have created a simple custom healthbar Gui that turns red when the player is damaged and turns back to the normal color after 1 second. However, I have noticed that if the player is damaged more than once within one second, the wait(1) does not "restart." In other words, the healthbar does not turn back to normal color after 1 second after the last time it was damaged. For instance, if the player is damaged, and then damaged again after 1 second, the healthbar does not turn red for the second time the player is damaged because the wait(1) from before causes the healthbar to turn back to normal color. If someone actually understood everything I just said, I would really appreciate it if you could explain to me how to solve this. Thanks in advance
--Defined variables above
humanoid.HealthChanged:connect(function(health)
healthBackground.BackgroundColor3 = Color3.fromRGB(200,0,0)--Damaged color
healthbar:TweenSize(UDim2.new(health/100,0,1,0), "Out", "Quint", 0.5, true) --Move healthbar
wait(1)
healthBackground.BackgroundColor3 = Color3.fromRGB(150,150,150) --Normal color
end)

1 comment
Oh, I forgot about debounces! Thank you very much