I’m trying to create a game loop that chooses a game, triggers another script that handles the chosen game, and continues the main game loop when that script is done. But I can’t figure out how to pause the main loop until the event is fired. How would I do this?
If that doesn’t make sense, I’m basically trying to pause a loop until a certain event is fired. lol
i think using the RemoteEvent:Wait() works for this. i may be wrong as i dont use :Wait() much.
yeah i think it yields the code until the event is connected
use RemoteEvent:Wait(), or if you wanna do it more complicated you can just have it with a repeat loop and then a actor sends data saying when it fired, but thats a waste of time, so yeah. RemoteEvent:Wait()
In Roblox, RBXScriptSignals (Events) have a :Wait method, which stops the current script until the event has been fired. When the event was fired, the script continues, and provides the values it was given.
local a = Event:Wait() -- Stops and returns the values if fired