while task.wait() and rept == true do
print(“repeating”)
end
wait(1)
rept = false
print(“break loop”)
This is just an example, but this code while running is not what i expected to be. So what i want to do is when it loops. It keeps looping until after the wait(1) . I have another solution that use:
for i = 1, 60 do – 1 second = 60 times of task.wait()
– which is 0.015 seconds
print(“repeating”)
task.wait()
end
print(“break loop”)
If there are more solutions about using loop please help me.
A bit confusing at first, but I think I got what you mean.
So you can actually create a new thread with either task.spawn or with the coroutine library like so (I’ll be using coroutine.wrap):
local coroutineSpawned = false
local dropLoop = false
for i = 1, 60 do -- 1 second = 60 times of task.wait()
if dropLoop then break end
-- which is 0.015 seconds
if not coroutineSpawned then
coroutine.wrap(function()
coroutineSpawned = true
task.wait(1)
dropLoop = true
end)()
end
print("repeating")
task.wait()
end
If you need an explanation, I’d be happy to explain it to you. Maybe not on my alt (this account that I’m on) though
Please type 3 backticks before and after your scripts when you put them here so they format properly.
I think I understand what you’re asking, try this:
local timer = 0
local rept = true
repeat -- this will run the following script until the conditions met in the until line below are met
timer += 1 -- adds one to the timer
print(timer)
print(rept)
-- you'll have to script how to change rept to false somewhere else
task.wait()
until rept == false or (not sure, you may have to add another *until* here) timer == 60
print("loop broken because rept changed to false, or timer reached 60")