So, I've come across the need to add a wait() function in a ModuleScript. I read on the wiki that when wait() is used in a ModuleScript, all other functions/scripts requiring the aforementioned ModuleScript will also wait. At least, that's my understanding of it. Is there a way to get around this?
What I'm attempting to do is have a for-loop pause what it's doing until a certain value becomes true.
For Example,
function GameManager:StartGame()
local Rainbow = false
--Skipping many lines of unrelated code
function ActuallyBeginGame()
for i = 1,Rounds do
SpawnThing1()
SpawnThing2()
SpawnThing3()
repeat wait() until Rainbow == true --If I did this right, the for loop should wait to execute any other code until Rainbow is true
Rainbow = false --Make Rainbow false to start the process over again.
end
end
end
I cant really test my game out at the moment, so I haven't tried experimenting on my own to see whether it works or not. I would use spawn(function), but since that just runs code instantly on a separate thread I'm afraid it wouldn't pause the for-loop.
So would using wait pause the whole module script, or just the for loop? Also, if it does, is there another way to do this? Any help is appreciated, and if anything needs clarifying let me know. Thanks! :)
P.S. If this is confusing, or something needs clarification, let me know. Thanks.

1 comment
Oh ok, thanks! :)