Yuari
Documentation
Docs/task library/task.cancel

task.cancel

Cancels a thread or a task.delay handle.

Syntax

task.cancel(thread: thread) -> boolean

Parameters

ParameterTypeDescription
threadthreadThe Luau thread to inspect.

Returns

TypeDescription
booleanThe 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.