Particle emmiter ripple effect

so I made a foor fountain with particle emmiter and I want to make a ripple effect but going from the inside to outside then inside again

this is how it looks like
image

basically the particle emmiter in the inner part is enabled then disable after some time then go to the second layer then do the same

in this pattern


(starts from red then go to blue on rainbow patter)

this is how it looks like so far


the problem is they dont go at the same time making the particles go at a random order

Script
local fountain = script.Parent

for i, v in pairs(fountain:GetDescendants()) do
	if v:IsA("ParticleEmitter") then
		v.Enabled = false
	end
end

task.wait()

while wait(0.3) do
	for i, v in pairs(fountain.A:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
			wait(0.2)
			v.Enabled = false
		end
	end
	wait(0.3)
	for i, v in pairs(fountain.B:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
			wait(0.2)
			v.Enabled = false
		end
	end
	wait(0.3)
	for i, v in pairs(fountain.C:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
			wait(0.2)
			v.Enabled = false
		end
	end
	wait(0.3)
	for i, v in pairs(fountain.D:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
			wait(0.2)
			v.Enabled = false
		end
	end
	wait(0.3)
	for i, v in pairs(fountain.E:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
			wait(0.2)
			v.Enabled = false
		end
	end
end

explorer:
image
(A - inner, E - outer)

Someone help me with this, thanks

You just need to remove pairs in all of them so they are consistent.

Or replace pairs with ipairs.

1 Like

its still the same with ipairs and without it

The for loop is waiting 0.3, then moving on the to the next ParticleEmitter, so they won’t happen all at once. You could use coroutines.
Also, at some points you’re using task.wait() and then wait()?? Please stick with task.wait().

-- this is probably not performant because of the insane amounts of coroutines generated.

local fountain = script.Parent

for i, v in pairs(fountain:GetDescendants()) do
	if v:IsA("ParticleEmitter") then
		v.Enabled = false
	end
end

task.wait()

while task.wait(0.3) do
	for i, v in pairs(fountain.A:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			coroutine.wrap(function()
				v.Enabled = true
				task.wait(0.2)
				v.Enabled = false
			end)
		end
	end
	task.wait(0.3)
	for i, v in pairs(fountain.B:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			coroutine.wrap(function()
				v.Enabled = true
				task.wait(0.2)
				v.Enabled = false
			end)
		end
	end
	task.wait(0.3)
	for i, v in pairs(fountain.C:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			coroutine.wrap(function()
				v.Enabled = true
				task.wait(0.2)
				v.Enabled = false
			end)
		end
	end
	task.wait(0.3)
	for i, v in pairs(fountain.D:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			coroutine.wrap(function()
				v.Enabled = true
				task.wait(0.2)
				v.Enabled = false
			end)
		end
	end
	task.wait(0.3)
	for i, v in pairs(fountain.E:GetDescendants()) do
		if v:IsA("ParticleEmitter") then
			coroutine.wrap(function()
				v.Enabled = true
				task.wait(0.2)
				v.Enabled = false
			end)
		end
	end
end
1 Like

oh I got it running, I used

local sprinkler = coroutine.wrap(function()
	v.Enabled = true
	task.wait(0.2)
	v.Enabled = false
end)
sprinkler()
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.