I have this script that doesn't remove the model when it dies
Script-
CarnoNPC = script.Parent
if CarnoNPC.Humanoid.Health == 0 then
CarnoNPC:Remove()
end
I have this script that doesn't remove the model when it dies
Script-
CarnoNPC = script.Parent
if CarnoNPC.Humanoid.Health == 0 then
CarnoNPC:Remove()
end
Looks like you are only checking the health once. Try this instead:
CarnoNPC.Humanoid.Died:Connect(function()
CarnoNPC:Destroy()
end)
That's a more efficient way to do it, however, in his case, the NPC will not get destroyed because the scripts will not run as it is in ReplicatedStorage.
You need to describe your changes.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
:Remove() is deprecated, use :Destroy() instead.