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

Help with loops

Asked by
Restic 15
10 years ago

I'm trying to make a script that prints numbers 1-10. While 'a' is less than or equal to 5, it should print "less than or equal to 5." While 'a' is greater than or equal to 6, it should print "greater than or equal to 6."

How can I fix this script, or make something scripted differently that does the same thing?

a=0
repeat
    a=a+1
    print(a)
    wait(1)
while a<=5 do
    print("less than or equal to 5")
    wait(1)
while a>=6 do
    print ("greater than or equal to 6")
    wait(1)
end
end
until a==10
0
This script was only made for me to learn. It's not intended to be in a game. Restic 15 — 10y

1 answer

Log in to vote
5
Answered by 10 years ago

Well, that is a way to do it I suppose.

Aswell, you could use a for loop, such as:

for i = 1,10 do
    if i <= 5 then
        print("less than or equal to 5")
    elseif i>= 6 then
        print('Bigger than 5")
    end
end
Ad

Answer this question