Runs the given callback after duration seconds. Returns a cancellation function.
duration
Note: This is functionally equivalent to task.delay, except a cancellation function is returned rather than the created thread.
task.delay
Seconds to wait before calling the callback function.
callback
The function to call.
Rest
Optional arguments to pass to the callback function.
Cancellation function.
const cancel = SetTimeout(1, () => { print("This code runs after 1 second");});// Optionally stop the timeout from running:cancel(); Copy
const cancel = SetTimeout(1, () => { print("This code runs after 1 second");});// Optionally stop the timeout from running:cancel();
Runs the given callback after
duration
seconds. Returns a cancellation function.Note: This is functionally equivalent to
task.delay
, except a cancellation function is returned rather than the created thread.