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

Help with body part particle emitters?

Asked by 6 years ago
Edited 6 years ago

So I was helped with adding fire to all the body parts when it touched with the fireball, however. I now want to get rid of the fire after a it does some damage (Simulating a burn effect).

  local fire = game:GetService("ServerStorage").ParticleEmitter
  for _, v in pairs(hit.Parent:GetChildren()) do
            if v:IsA("BasePart") then 
                if not v:FindFirstChild("ParticleEmitter") then
                    fire:Clone().Parent = v 
--Solved^^^
    for i = 1, 10 do 
      hit.Parent.Humanoid:TakeDamage(1)
      wait(0.5)
    end

wait(5)
for _, v in pairs(hit.Parent:GetChildren()) do
        if v:IsA("BasePart") then 
                if v:FindFirstChild("ParticleEmitter") then
                    v.ParticleEmitter:Destroy() 
        end
    end
            end
--Unsolved^^^

1 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Use the Debris Service.

local debrisService = game:GetService("Debris")
local fire = game:GetService("ServerStorage"):FindFirstChild("ParticleEmitter")
    for _, v in pairs(hit.Parent:GetChildren()) do
        if v:IsA("BasePart") then 
            if not v:FindFirstChild("ParticleEmitter") then
                local fireClone = fire:Clone()
                fireClone.Parent = v
                debrisService:AddItem(fireClone, 5) -- removes the object in 5 seconds

for i = 1, 10 do 
    hit.Parent.Humanoid:TakeDamage(1)
    wait(0.5)
end

Hope this helps! :)

0
Oh wow, I completely forgot about Debris XD. Thanks so much DominousSyndicate 41 — 6y
0
a combo of my script and chomboghai's script is heaven (the script was my answer lol) User#19524 175 — 6y
Ad

Answer this question