Task
ℹ️
Page is being worked on.
A built-in library to access the task scheduler.
Task scheduler is designed to be similar to Roblox's task scheduler.
Functions
Functions
cancel
task.cancel(thread: thread): ()
Cancels a task.
Parameters
thread: thread
- The thread to cancel.
defer
task.defer<A..., R...>(f: ((A...) -> R...) | thread, A...): thread
Defers a task.
Runs on next frame.
Parameters
f: ((A...) -> R...) | thread
- The function to defer.A...
- The arguments to pass to the function.
Returns
thread
delay
task.delay<A..., R...>(sec: number, f: ((A...) -> (R...)) | thread, A...): thread
Delays a task.
Runs after a certain amount of time.
Parameters
sec: number
- The amount of time to delay.f: ((A...) -> (R...)) | thread
- The function to delay.A...
- The arguments to pass to the function.
Returns
thread
spawn
task.spawn<A..., R...>(f: ((A...) -> (R...)) | thread, A...): thread
Spawns a task.
Runs immediately.
Parameters
f: ((A...) -> (R...)) | thread
- The function to spawn.A...
- The arguments to pass to the function.
Returns
thread
wait
task.wait(sec: number?): number
Sleeps task.
Yields caller. Resumes after a certain amount of time.
Parameters
sec: number
- The amount of time to wait.- Default:
0
- Default:
Returns
number
- The amount of time waited.
count
task.count(): number
task.count(kinds: string?): ...number
Counts the number of tasks.
Optional kinds parameter to count a specific kind of task.
Kinds:
s
to count sleeping tasks.d
to count deferred tasks.w
to count awaiting tasks. (Zune backend)t
to count internal tasks. (Zune backend)
Parameters
kinds: string?
- The kinds of tasks to count.- Default:
nil
- Default:
Returns
number
|...number
- The number of tasks.