Hi, I'm building a game using Lua, including the built-in functions Roblox provides. However, this question isn't Roblox specific = I think it can apply to anything using Lua language. However, just be aware that the solution can involve Roblox-Built-In functions. So I have a script, however, I need it to wait until one of my values is equal to 1. It's like a flag. While I'm familiar with the wait() function that allows one to pause the script for several seconds, I'm not sure how to do something like "Wait until Flag.Value = 1". I have a local function I wish to run, but only when the Flag's value is equal to 1.
What I have tried:
I've already tried a few approaches, such as using a while true loop. I wrote something like this:
while true do
if Flag.Value = 1 do
However, this returns an error: "Script timeout: Exhausted allowed execution time". I'm not sure if this error is related, but when I got rid of my loop and just called the function, there was no error. Is there a way to do a statement like "wait until"? Thanks