New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
-1

# How do I make a complicated script loop infinitely?

Ok, I'm trying to finish my rain script but I don't know where to put a repeat script. Here is the script:

game.Workspace.Rainpart.Transparency = 1
game.Workspace.Rainpart.ParticleEmitter.Enabled = false
wait(5) -- This is how much time before the initial clouds form.
do game.Workspace.Rainpart.Transparency = 0.5 -- This is the transparency of the initial cloud
game.Workspace.Rainpart.ParticleEmitter.Enabled = false -- Don't change this!
wait(2.5) -- When changing this...change the number in between 2 and 5.
game.Workspace.Rainpart.Transparency = 0 -- This shows the transparency of the main cloud.
game.Workspace.Rainpart.ParticleEmitter.Enabled = true
game.Workspace.Rainpart.ParticleEmitter.Acceleration = 0,-20,0
game.Workspace.Rainpart.ParticleEmitter.Rate = 50
game.Workspace.Rainpart.ParticleEmitter.Speed = 5
wait(7.5)
game.Workspace.Rainpart.Transparency = 1
game.Workspace.Rainpart.ParticleEmitter.Enabled = false
wait(5)

end



All I need to finish this is where to put a repeat script. Does anyone know where I should put a repeat script?

0
Looping your script would be very "inefficient". This is because you'll have to loop the edits in properties even when it's not necessary! Enabled particles means the "rain" in your case will contiguously fall. Disabled will stop the spawning of more particles, the ones that exist will stay until lifetime ends! alphawolvess 1699 — 4y

3

ParticleEmitters will continue forever when enabled. You should make the ParticleEmitter already exist and placed correctly.

Now, I'll assume at some point you'll want it to stop then continue. So, assuming you did what I mentioned and the part with ParticleEmitter already exists and all the properties are correct, leave it enabled or disabled at first so it will appear raining.

Here's a script to turn it on/off:

while true do
wait(5)-- Wait 5 before starting rain
game.Workspace.Rainpart.Transparency = 0
game.Workspace.Rainpart.ParticleEmitter.Enabled = true
wait(5) -- Wait 5 then stop raining
game.Workspace.Rainpart.Transparency = 1
game.Workspace.Rainpart.ParticleEmitter.Enabled = false
end


This makes it much easier to work your cloud.

• Remember , Particles will seem like there's a lower amount when your graphics are lower, the higher graphics the more/better it'll be visible!

To make a part (In your case cloud) appear and disappear, you can use a while true do loop. All you'll be doing is changing the transparency and then using a wait so nothing will happen for that amount of time, then change the transparency again, with another wait then this will repeat. Look bellow for a script example!

while true do -- endless loop! No waits will crash studio/game!!
game.Workspace.Cloud.Transparency = 0 -- I'm saying cloud just as an example
wait(10) --This cloud will have 0 transparency for 10 second because the script is waiting 10 seconds before doing the code bellow!
game.Workspace.Cloud.Transparency = 1
wait(10) -- This will wait 10 seconds before replaying the script(After 10 seconds it will switch to the code making it have 0 transparency and so on)
end

0
No, what I mean is that for example, a cloud forms, then it disppers, then it appears again and so on..how do I make that repeat? VCRaygamma 15 — 4y
0
You really need to work on making your questions if that's what you really want. I added the answer to this new question in my answer. alphawolvess 1699 — 4y
0
(off topic) How do you make those black circles? Vlatkovski 320 — 4y
0
(Off topic) Black circles? Oh and it makes more sense now. Thanks! VCRaygamma 15 — 4y