So im working on this Post Apocalyptic game and it should include Dust Storms,
i have done it like this:
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
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
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
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.
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.