task.cancel

Cancels a pending executor coroutine.

Syntax

Signature
task.cancel(Thread: thread) -> ()

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
ThreadthreadCoroutine to inspect or cancel.

Returns

TypeDescription
()None.

Notes

Raises an error if the coroutine is no longer scheduled by this environment.

Example

Luau
local Thread = task.delay(30, function() print("Later") end)
task.cancel(Thread)