Hello I am very new to scripting and I was wondering how to make a randomly timed explosion particles. I know how to do the explosion part I just have to enable and disable the particle but I am not sure how to randomate it. I tried using wait but it just does it like every 10 seconds I want it to be random.
You can make it wait a random time via
wait(math.random(5,10))
Where 5
is the minimum wait time and 10
is the maximum wait time that it’ll explode, in seconds of course
use math.random for partical and math.random for the time
wait((math.random(1,5)*60))
-- here it explodes
goes from one to five mins
Thank you I think I done it now
Anytime! if you have anymore issues don’t be afraid to make another post!
Also how could I repeat it? Or does it already repeat it self
It’ll get a random number the next time you make the explosion happen, so say you have an explosion happen and it waited 7 seocnds, next time it happens it may wait 9 seconds, it’s not set to a varaible so it’ll get another random number
this is in seconds tho to achieve minutes multiply by 60
@OP didn’t specify seconds or minutes
I meant does it repeat every time after it explodes? Like let say it exploded once will it explode again or do I need to code a repeat script?
You’ll have to make it repeat yourself, this code I gave just randomizes a wait time
Alright I think I can figure that out thanks
while true do
wait((math.random(1,5)*60))
--explode
end
remove the *60 part for seconds
Anytime! If you want it to repeat infinitely with random wait times, you could do
while wait(math.random(5,10)) do
--code
end
If needed, again it depends on your usecase
I did some fixing my self and it worked just as I wanted it to thank you very much