Best Timed-Loop?

What’s the best async’d (task,multi-threaded) way to make a loop that runs every 10 minutes.

Typing on phone, excuse the bad formatting.

It would probably look something like this (if i understood your question properly):

coroutine.wrap(function()
   while task.wait(600) do — 10 minutes = 600 seconds
      —code here
   end
end)()

Shouldn’t be too complicated.

2 Likes

Knew this existed, just looking for the most performant method.

That would already be performant enough, however you could do this which would also be an alternative if you are trying to check if something has changed in a Period of time:

local timestart = tick()

while task.wait() do
    if tick() - timestart >= 600 then
        -- code
    end
end

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