How do I enable multiple particles at once

Hi,

I’m making a menu for my game
and I wanted to add a cool glitch effect using particle emitters
I wanted to enable them at once after a event so I used for in do
here is my script:

for i,v in pairs(part:GetDescendants()) do
	if v:IsA("ParticleEmitter") then
		anim:Play() --a tween animation
		wait(8)
		textlabel.Visible = false -- text
		smile.Visible = true -- text
		blue.Visible = true -- chromatic aberration effect
		red.Visible = true -- chromatic aberration effect
		blue:TweenPosition(UDim2.new(.51,0,.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,1)
		red:TweenPosition(UDim2.new(.49,0,.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,1)
		v.Enabled = true -- particle effect
		wait(100) -- set to 100 cuz test
		v.Enabled = false
		smile.Visible = false
		blue.Visible = false
		red.Visible = false
	end
end

image

I did try to search some solution but they’re the same thanks in advance

2 Likes

Try this

for i,v in pairs(part:GetChildren()) do
	if v:IsA("Attachment") then
    local Attachment = v

for I,V in pairs(Attachment:GetChildren()) do

if V:IsA("ParticleEmitter") then

	anim:Play() --a tween animation
		wait(8)
		textlabel.Visible = false -- text
		smile.Visible = true -- text
		blue.Visible = true -- chromatic aberration effect
		red.Visible = true -- chromatic aberration effect
		blue:TweenPosition(UDim2.new(.51,0,.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,1)
		red:TweenPosition(UDim2.new(.49,0,.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,1)
		V.Enabled = true -- particle effect
		wait(100) -- set to 100 cuz test
		V.Enabled = false
		smile.Visible = false
		blue.Visible = false
		red.Visible = false
	end
end

end
end
		
1 Like

The problem is the wait() yields the function, this means you will need to run the function in parallel. Simply do

for _,v in pairs(Attachment:GetChildren()) do
    spawn(function()
    -- code
    end)
end
1 Like

Thanks it work as I expected spawn is new to me i’ll try learning that too

1 Like

It didn’t work im sure that :GetDescendants is the same with :GetChildren but shorter

:GetChildren = Will get the Objects that are IN model
:GetDescendants = Will get Objects that are in parts in the model

I just learned about :GetDescendants thanks for correcting me

1 Like

Your welcome, the :GetChildren and :GetDescendants are useful

1 Like