task.delay
Schedules a function to run after a delay.
Syntax
Signature
task.delay(Seconds: number, Callback: function, ...: any) -> threadAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Seconds | number | Delay in seconds from 0 through 86400. |
Callback | function | Function to run. |
... | ...any | Arguments passed to Callback. |
Returns
| Type | Description |
|---|---|
thread | New coroutine queued for execution. |
Notes
The callback runs on a scheduler tick after the delay, so it may run later than requested.
Example
Luau
local Started = os.clock()
local Job = task.delay(1, function(Message)
print(Message, os.clock() - Started)
end, "Delayed callback")
print("Queued coroutine:", Job)