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

While loop simple counter not working? [solved]

Asked by 5 years ago
Edited 5 years ago

Hello,

I want to make a simple counter in the output which will increase every second.

Here is my code but it doesn't seem to work as I expected:

while true do
wait(1)
print'1'
end

Help will be appreciated.

1 answer

Log in to vote
0
Answered by 5 years ago

Hello,

What you need to use is a for loop.

Here is the code:

for i = 1, 10 do --change ten with the max counter number
    wait(1)
    print(i)
end

Frag

0
Your code will just print the number '1' forever in the output. Fragmentation123 226 — 5y
0
Thank's it helped, I assume that if I change the wait() rate,the number between prints will change. ExploitInstance 30 — 5y
0
Yeah, you can also change the max number of the counter (see comment). Fragmentation123 226 — 5y
Ad

Answer this question