Home / Timers

every()

every(ticks, handler)

Schedules a repeating task that runs every specified number of server ticks.

Parameters

NameTypeDescription
ticksintegerPeriod in ticks. Values below 1 are clamped to 1 tick; 20 ticks is approximately 1 second.
handlerfunctionCalled as function(task).

Returns

A task handle.

Example

local task = every(20, function(task)
  log("tick " .. server.ticks())
end)

-- Later: task:cancel()

Notes

Avoid expensive work in every(1, ...). It runs every game tick on the server thread. The task handle's cancel() method stops the repeating task.