How to make a loop only happen for a given amount of time

Hello,

I have this while true do loop below which loops a print forever. How can I make it so it only loops this process for 10 seconds?

while true do
	wait(0)
	print("One cycle completed")
	wait(1)
end

You could use a for loop for this, like so:

for i = 1, 10 do -- starts from x (1), until y (10)
    task.wait(1)
    print('Cycle completed, on', i) 
    -- every time loop runs, 'i' is the number of the current cycle
end
1 Like

Awesome, thanks so much! I’ll test this… and if it works, I will mark it as my solutuion.

2 Likes
for i = 10, 0, -1 do
	print(i)
	task.wait(1)
end

If you’re looking for a timer.

2 Likes

what do these numbers mean?

iebfixjwhfoxohwjrkdjwbei