Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

While loop simple counter not working? [solved]

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

✓ Accepted answer

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

3 comments

0

Your code will just print the number '1' forever in the output.

0

Thank's it helped, I assume that if I change the wait() rate,the number between prints will change.

0

Yeah, you can also change the max number of the counter (see comment).

This discussion is preserved as it was. New answers, comments, and votes are closed.