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 7 years ago
repeat wait(1) until Term.BrickColor == BrickColor.new("Navy blue")
    if TUW <= 1200 and TUW > 0 then
        TUW = TUW - 1
        print(TUW)
        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 7 years ago
Edited 6 years ago

You're not understanding how a repeat loop works.

repeat
    --// This is what loops.
until (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.

repeat 
    wait(1) 
until Term.BrickColor == BrickColor.new("Navy blue")

if TUW <= 1200 and TUW > 0 then
    TUW = TUW - 1
    print(TUW)
    script.Parent.CT.Text = tostring(TUW)
end

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

repeat 

    if TUW <= 1200 and TUW > 0 then
        TUW = TUW - 1
        print(TUW)
        script.Parent.CT.Text = tostring(TUW)
    end

    wait(1) 
until Term.BrickColor == BrickColor.new("Navy blue")

print("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