BillboardGui dosen't change its color

Hello developers! So I am trying to make a percentage BillboardGui that displays the life of a dummy, and I want it to turn red when the dummy gets damage. This works perfectly fine, but after the dummy dies the billboardGui stops turning red.

I think is because after the dummy dies, the script wants to color the old BillboardGui that dosen’t exist anymore(the one that the dead dummy had) and not the current one. Thats why I added :WaitForChild, but still nothing happens.

Here is the code:

local dummy = script.Parent
local humanoid = dummy.Humanoid

local percentage = 100
local currentHealth = humanoid.MaxHealth

humanoid.HealthChanged:Connect(function()
	
	currentHealth = humanoid.Health
	percentage = 100 * (currentHealth / humanoid.MaxHealth) +1
	dummy:WaitForChild("Head").BillboardGui.TextLabel.Text = math.round(percentage).."%"
	
	   while dummy:GetAttribute("getsAttacked") == true do
		
		dummy:WaitForChild("Head").BillboardGui.TextLabel.TextColor3 = Color3.new(1, 0, 0)
	    wait()
	end
		
		
		wait(.25)
		dummy:WaitForChild("Head").BillboardGui.TextLabel.TextColor3 = Color3.new(1, 1, 1)
end)

Please tell me if I need to provide more details.

Try using Humanoid.Died:Connect instead, and wait a few moments after the dummy dies before destroying it just to be sure you can see the billboard change colors. Try adding it to debris with a delay instead of directly destroying it.

1 Like

ty, I’ll try that as soon as I can, and I will inform you if it worked.