Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is repeat until nil an infanite loop?

Is repeat until nil an infanite loop?

1 answer

✓ Accepted answer

Yes.


repeat loops work similarly to while loops, with two differences:

  1. They only check the condition after running the first time (while loops act like if statements for the first time)

  2. repeat loops stop on a truey value (until implies you are waiting for something) while while loops stop on a falsey value.

There are two "falsey" values: false and nil. All others are "truey".

So,

repeat until nil is the same as the perhaps more recognizable repeat until false

Since the condition nil (or false) is a constant and always falsey, it can never change to indicate the loop will stop. So the loop is infinite and will continue on until a break or return.

This discussion is preserved as it was. New answers, comments, and votes are closed.