task.delay
Schedules fn to run after seconds. Returns a handle usable with task.cancel.
Syntax
task.delay(seconds: number, fn: function) -> thread
Parameters
| Parameter | Type | Description |
|---|---|---|
seconds | number | A duration in seconds. |
fn | function | The function or callback to use. |
Returns
| Type | Description |
|---|---|
thread | Thread handle |
Description
task.delay is part of the task library library. The task library runs on the VM's own scheduler; waits and delayed callbacks resume when the VM next ticks.
The operation is performed immediately using the arguments supplied at the call site.
Example
local handle = task.delay(1, function()
print("delayed")
end)
print(handle)
Notes
- Waits and delayed callbacks resume on the VM's scheduler.