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

Help with body part particle emitters?

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

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! :)

2 comments

0

Oh wow, I completely forgot about Debris XD. Thanks so much

0

a combo of my script and chomboghai's script is heaven (the script was my answer lol)

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