Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ParticleEmitter on death of zombie not working?

Asked by
RoyMer 301 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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.

0
Thanks! :D RoyMer 301 — 8y
0
No problem. Spongocardo 1991 — 8y
Ad

Answer this question