Dead NPC With Billboard Gui That Duplicates After Death

I’m trying to fix a bug where a billboard Gui duplicates itself in a spot on the baseplate after death.

image
Here’s the LocalScript that I used to try to fix this issue and be a solution.

Code Inside of The Script:

local health = script.Parent.Parent.Parent.Humanoid.Health

if health < 1 then
	script.Parent.Visible = false
end
-- Don't mind my horrible scripting please.

Photo of Issue:

cant u just delete the billboard GUI?

also i assume the zombie has a humanoid so you can use the humanoid.Died function

1 Like

bro wym zombie :skull::skull:
i never said zombie lol

oh well my bad i meant to say dead npc

1 Like

Nothing happens to the Billboard.

if health < 1 then
	script.Parent.Visible = false
end

This will only run once, and unless the NPC is already dead upon the LocalScipt being loaded, it will read that the health of the NPC is above 1 and finishes; nothing else will happen from that point. Instead, you would want to be constantly listening for the NPC’s health. This can be done with the following:

  • Condition-controlled loop, also known as a while loop
  • .Changed event
  • :GetPropertyChangedSignal()
  • .Died event

Since you’re dealing with an NPC, the .Died event would be what you would want to use in this situation (assuming the NPC has a Humanoid object), just like how @Unknown91248 has mentioned. The .Died event fires after the Humanoid, well, dies, which is perfect for your situation as you want the Billboard to disappear after the NPC dies.

npcHumanoid.Died:Connect(function()
    script.Parent.Visible = false
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.