Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ParticleEmitter on death of zombie not working?

This script is inside the Humanoid of the Zombie, when the health of the Zombie is 0 it should enable the particles for 5 seconds. (The ParticleEmitter is inside the torso)

local emitter = script.Parent.Torso.ParticleEmitter
local starter = script.Parent

if starter.Health == 0 then
	emitter.Enabled = true
	wait(5)
	emitter.Enabled = false
end

1 answer

✓ Accepted answer

You're only checking if the Health is 0 once. You need to use either a loop or more preferably, an event, to make sure it keeps checking if the health is 0.

local emitter = script.Parent.Torso.ParticleEmitter
local starter = script.Parent

starter.HealthChanged:connect(function(health) --Anonymous function which fires every time the player's health changes. The health parameter is how much health the humanoid is at now,
	if health ~= 0 then return end --If the player isn't dead, stop the function.
	emitter.Enabled = true
	wait(5)
	emitter.Enabled = false
end) --Closing parenthesis to wrap the function in the connection to the event.

I hope my answer helped you. If it did, be sure to accept it.

2 comments

0

Thanks! :D

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.