Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

If a while loop is running, can the code under it run at the same time?

Asked by 9 years ago

To elaborate... If I'm running a loop, does it just loop that code over and over without running any code I put below it? Sorry if this is obvious.

2 answers

Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

The script loops the code over and over without running any code below it.

...Unless if you used a coroutine.

0
Thank you! dirty_catheter 7 — 9y
0
You're welcome. Redbullusa 1580 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Typically it would loop infinitely, until you break it or until it reaches it's goal. You can run code while also running a loop by using coroutines:

coroutine.resume(coroutine.create(function()
while true do print("apple")
wait(0.1)
end
end))

print("I'm still running!")

Answer this question