Reverse for loop

how can I make a for loop so the printing is 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 something like that

for i = 10, 1, -1 do
    print(i)
end
5 Likes

without using that method, like do it inside the for loop

What would be effective use for this? You’ve gotten your information from that loop, why do you need to complicate it further?

1 Like

This:

local number = 10

while task.wait() do
print(number)
number -= 1
if number == 1 then
print(number)
break
end
end

or

local number = 10

repeat task.wait()
print(number)
number -= 1
until number == 1
print(number)

Or anon_j1124 Answer.

Why would you need to do this with a wait loop? Just use a for i = number,1 loop…

This is extremely inefficient…

I know, but he asked for this answer thats because i also wrote Or anon_j1124 Answer.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.