I have a zombie and a script to get rid of it after it has reached zero health. The only problem is that the script doesn't destroy the zombie. Note: The zombie does disappear but it takes somewhere around 10-15 seconds. Here's the script, the humanoid is named "Zombie", and the script is a direct child to the model.
local function die()
workspace.CountDown.Value = workspace.CountDown.Value - 1
script.Parent:Destroy()
end
script.Parent.Zombie.Died:Connect(die)

4 comments
You are making it way harder than it actually has to be. All you need to do is check for the Died event of the Humanoid, and destroy the zombie when the event fires. Furthermore, you can put a while loop within the function that will keep looping until the countdown reaches 0.
I've now updated it to use the Die event. The countdown is to countdown the amount of zombies left. So, with this I was thinking that it would just destroy itself and disappear right after it reaches 0 health. But that's not what's happening. There's always a delay before it actually kills itself, it can be from 3 to 15 seconds. Is there a way to get rid of the delay altogether? Thx in advance
Is the countdown immediately after or is it inside the loop?
The CountDown is an int value instance in the workspace. I use it to countdown the game and after the game has started, it is used to keep track of the zombies. Once it reaches 0, the game will end and wait for enough players to restart. If that is effecting the script I can move it to a script in sss that handles a kill event.