I'm researching Lua in Roblox and came across this word. Please explain what she is responsible for?
what is the reserved keyword "break" in Lua responsible for? What is it for ?
1 answer
so if you're running a loop and there's the word "break" inside, it means that you wanna stop the loop:
for i = 1, 10 do -- this is a loop
print(i) -- printing the number which "i" is at, in the output
if i == 5 then -- if i is equal to 5,
break -- this will stop the loop
end
end
try it, and watch carefully in the output. To open the output, click "View" on the tab up on the screen, try to find "Output" and click it. Did you see, it printed the numbers all the way to 5, and not to 10, because when it arrived at 5, we broke the loop with the word "break".
Hope this helped!
For more info, check here https://developer.roblox.com/en-us/articles/Loops
3 comments
Extension to this answer: The break keyword only breaks the current thread loop. This means that if you have a for loop inside a while loop and you break the for loop, the while loop will keep going.
yes i forgot to write that, thx
cuz i couldn't edit my answer smh
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I will advise you to do more research than to be asking in this site.
I'm just still the new guy. and I didn't find it on the roblox site.