task.cancel
Cancels a thread or a task.delay handle.
Syntax
task.cancel(thread: thread) -> boolean
Parameters
| Parameter | Type | Description |
|---|---|---|
thread | thread | The Luau thread to inspect. |
Returns
| Type | Description |
|---|---|
boolean | The boolean result of the check. |
Description
task.cancel 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 call is a predicate: it inspects the current state and returns a boolean without modifying anything.
Example
local handle = task.delay(5, function()
print("never runs")
end)
task.cancel(handle)
Notes
- Waits and delayed callbacks resume on the VM's scheduler.