task.delay

Schedules a function to run after a delay.

Syntax

Signature
task.delay(Seconds: number, Callback: function, ...: any) -> thread

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
SecondsnumberDelay in seconds from 0 through 86400.
CallbackfunctionFunction to run.
......anyArguments passed to Callback.

Returns

TypeDescription
threadNew 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)