How do i make this Particle emitter not stop inmediantly when removed or ended

So im working on this Post Apocalyptic game and it should include Dust Storms,
i have done it like this:
Duststormrobloxstudioplzhelp

this is the script

local DustStormlvl1 = game.ServerStorage["DustStormWalllvl1"]

	wait(math.random(1, 10))
    local DustStormlvl1 = game:GetService("ServerStorage"):WaitForChild("DustStormWalllvl1"):Clone()
    DustStormlvl1.Parent = workspace
	print('DesertStormLevel1 has emerged')

		wait(math.random(60,420))
		workspace.DustStormWalllvl1:Destroy()
			print('DustStormLVL1 has stopped')

i dont want the particles to just disappear rightt away when it stopped, should i just move the entire thing into workspace and somehow get a script to change the particle emitter properties, but wouldnt that also cause them to disappear inmediantly
help is apreciated thanks for reading

Enabled = False each partical emitter by using a for loop,
wait(How ever long it takes for particals to disapear).
ParticalEmitter:Destroy()

1 Like

Pretty much was @anon25856735 said. To be more specific, it would probably be more beneficial to wait for however long the ParticleEmitter’s lifetime is so that the effect doesn’t just disappear while the particles are still in the air.

If the lifetime of a your particular ParticleEmitter is 10, then soon after disabling, you should have a wait(10), or slightly longer, afterwards before removing it.

Ex.

for c, child in next, DustStormlvl1:GetDescendants()) do
     if child.className == "ParticleEmitter" then --- The particle emitter reference is 'child'.

          local disappearing = false --- The debounce.

          child.changed:Connect(function(Stop)
          if disappearing == false then
               disappearing = true
               wait(child.Lifetime.Max) -- Make sure to put in  the ".Max". Even if lifetime is one number...
               --- the number range value will still have a min and max.
               --- Make sure the wait is IN the changed event like this, or else every storm in the game...
               --- Will wait 10 seconds for each other to disappear...
               child.Parent = nil
          end)

          child.Enabled = false
     end
end
2 Likes

so basically like this

local DustStormlvl1 = game.ServerStorage["DustStormWalllvl1"]

	wait(math.random(1, 10))
    local DustStormlvl1 = game:GetService("ServerStorage"):WaitForChild("DustStormWalllvl1"):Clone()
    DustStormlvl1.Parent = workspace
	print('DesertStormLevel1 has emerged')

		wait(math.random(60,420))

for c, child in next, DustStormlvl1:GetDescendants()) do
     if child.className == "ParticleEmitter" then --- The particle emitter reference is 'child'.

          local disappearing = false --- The debounce.

          child.changed:Connect(function(Stop)
          if disappearing == false then
               disappearing = true
               wait(child.Lifetime.Max) -- Make sure to put in  the ".Max". Even if lifetime is one number...
               --- the number range value will still have a min and max.
               --- Make sure the wait is IN the changed event like this, or else every storm in the game...
               --- Will wait 10 seconds for each other to disappear...
               child.Parent = nil
          end)

          child.Enabled = false
     end
end

the particle emitters arleady got everything set up

Yes, that’s definitely how you would do it.

1 Like

[18:18:13.009 - ServerScriptService.DustStorm Cycle:10: Expected ‘do’ when parsing for loop, got
there is a double “)”, do i get rid of one?

thats the cmd output btw (30characters)

My apologies - Yes you get rid of one.

i tried it but i think outcome is the same, let me see
" ServerScriptService.DustStorm Cycle:23: Expected identifier when parsing expression, got ‘)’"

You shouldn’t use wait() for that. Use Debris instead.

particleEmitter.Enabled = false
game:GetService('Debris'):AddItem(particleEmitter, particleEmitter.Max)

I didn’t test my code, so it had some typos. I just tested it now, and here is the code without typos:

for c, child in next, DustStormlvl1:GetDescendants() do
	if child.className == "ParticleEmitter" then --- The particle emitter reference is 'child'.

	local disappearing = false --- The debounce.

	child.changed:Connect(function(Stop)
		if disappearing == false then
			disappearing = true
			wait(child.Lifetime.Max) -- Make sure to put in  the ".Max". Even if lifetime is one number...
			--- the number range value will still have a min and max.
			--- Make sure the wait is IN the changed event like this, or else every storm in the game...
			--- Will wait 10 seconds for each other to disappear...
			child.Parent = nil
		end
	end)

		child.Enabled = false
	end
end

Although what @MalosVindictus is more effective - I just never got to using Debris service.

1 Like

Is that an edit to what Bruiselgnio sAID?

Nope, it’s the entire thing, so instead of what I wrote, you would do something like this -

for c, child in next, DustStormlvl1:GetDescendants() do
	if child.className == "ParticleEmitter" then --- The particle emitter reference is 'child'.

		child.Enabled = false
        game:GetService('Debris'):AddItem(child, child.Lifetime.Max)
	end
end

And you will get the same effect - I just tested it.

N.I.C.E bro, no errors for now, lets check if it works tho! might take up to 8 min to find out

1 Like

update: ok it has emerged, lets see if it also will “unmerge” smoothly

OK I recorded it because i had to go to sleep, i checked the recordings and saw the Dust Storm slowly disappearing, thanks alot!

oh and, just to know, how can i make it be looped (basically a storm can emerge any time)

edit: i got it working, i used while true do statements.

but just to be safe, how do i make the Dust Storms not start into each other

(remind me tomorrow to input the code here cuz its midnight rn and i gtg off if you want the script)