Yuari
Documentation
Docs/task library/task.delay

task.delay

Schedules fn to run after seconds. Returns a handle usable with task.cancel.

Syntax

task.delay(seconds: number, fn: function) -> thread

Parameters

ParameterTypeDescription
secondsnumberA duration in seconds.
fnfunctionThe function or callback to use.

Returns

TypeDescription
threadThread 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.