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

So apparently this loop is not working, do any of you know why? It's a loop centered around colors. [closed]

Asked by 8 years ago
1repeat wait(1) until Term.BrickColor == BrickColor.new("Navy blue")
2    if TUW <= 1200 and TUW > 0 then
3        TUW = TUW - 1
4        print(TUW)
5        script.Parent.CT.Text = tostring(TUW)

Locked by OldPalHappy

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
6
Answered by 8 years ago
Edited 7 years ago

You're not understanding how a repeat loop works.

1repeat
2    --// This is what loops.
3until (condition)

A repeat loops is a lot like a while loop, except a while loop checks the condition first, while as a repeat loop checks its condition last.

This answer will help you understand them more.

I'm not sure what this code is even suppose to do, but you're missing an end, and that's basically all the syntax errors fixed.

1repeat
2    wait(1)
3until Term.BrickColor == BrickColor.new("Navy blue")
4 
5if TUW <= 1200 and TUW > 0 then
6    TUW = TUW - 1
7    print(TUW)
8    script.Parent.CT.Text = tostring(TUW)
9end

If I were to guess I would say you meant to include your conditional statement in the loop:

01repeat
02 
03    if TUW <= 1200 and TUW > 0 then
04        TUW = TUW - 1
05        print(TUW)
06        script.Parent.CT.Text = tostring(TUW)
07    end
08 
09    wait(1)
10until Term.BrickColor == BrickColor.new("Navy blue")
11 
12print("Done")

If this isn't the answer you were looking for, please explain more what it is you're trying to do.

More Info.

Ad