Is there a feature in Roblox Lua where if a a certain requirement is met, the loop starts again from the beginning?
COMMUNITY QUESTION
Function That Starts Loop From Beginning Upon Requirement Being Met ?
1 answer
Well, there are a couple things you can do.
For 1, you can put a conditional statement (If Statement) and then a loop under it so it will run if the requirement is met.
An example is:
local a = true
if a = true then
while true do
wait()
print('a is true')
end
end
Another thing you can do is combine the loop with the statement. This is commonly used in infinite loops. Here is an example:
local a = true
while a do -- this is equal to while true do since a is true now u can put other statements such as 1 + 1 = 2 and so on
wait()
print('dis works')
end
If you wish to loop for a specific amount of times every second:
local a = true
if a then
for i = 0, 10 do -- loops 10 times
wait()
print('Looped'..i)
end
end
Hopefully, this helped and was what you were looking for.
Best of luck developer!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
http://robloxdev.com/articles/Roblox-Coding-Basics-Loops#For
I dont know if this applies to your situation, but if you're using any type of Value (Bool, Int, Number, Object) you can do Value.Changed event for a function. "Value.Changed:connect(function()"