Handle
A reference to a single scheduled task, returned by Scope scheduling methods.
Use a Handle to cancel, pause, resume, or reconfigure a task after scheduling.
A Handle becomes invalid when :cancel() is called or when the parent Scope
is destroyed. Calling any method on an invalid Handle throws an error.
local handle = scope:every(5, function()
print("tick")
end)
handle:pause()
handle:setInterval(10)
handle:resume()
handle:cancel()
Functions
cancel
Handle.cancel(self: HandleInternal) → ()Removes this task from the schedule permanently. The Handle becomes invalid immediately and cannot be paused, resumed, or cancelled again.
Errors
| Type | Description |
|---|---|
| "Handle is already cancelled" | Thrown if called on an already-cancelled Handle. |
| "Parent scope is destroyed" | Thrown if the parent Scope was destroyed. |
pause
Handle.pause(self: HandleInternal) → ()Pauses execution of this individual task. The task will not fire while paused, regardless of the parent Scope's own pause state.
Calling pause() on an already-paused Handle is a no-op.
Errors
| Type | Description |
|---|---|
| "Handle is cancelled" | Thrown if the Handle is invalid. |
| "Parent scope is destroyed" | Thrown if the parent Scope was destroyed. |
resume
Handle.resume(self: HandleInternal) → ()
Resumes execution of this task after handle:pause(). If the parent Scope is
also paused, the task will not fire until the Scope is resumed as well.
Errors
| Type | Description |
|---|---|
| "Handle is cancelled" | Thrown if the Handle is invalid. |
| "Parent scope is destroyed" | Thrown if the parent Scope was destroyed. |
setInterval
Handle.setInterval(self: HandleInternal,interval: number--
New interval in seconds.
) → ()
Changes the execution interval for every or tick tasks. The accumulated
time resets, so the next execution happens interval seconds from this call.
CAUTION
Only valid for Handles created with scope:every() or scope:tick(). Calling
this on an after or frame Handle throws an error.
Errors
| Type | Description |
|---|---|
| "setInterval is only valid for 'every' and 'tick' handles" | Thrown for incompatible handle types. |
| "Handle is cancelled" | Thrown if the Handle is invalid. |
| "Parent scope is destroyed" | Thrown if the parent Scope was destroyed. |
isPaused
Handle.isPaused(self: HandleInternal) → boolean
Returns whether this individual task is paused. Does not account for the
parent Scope's pause state — only reflects whether handle:pause() was called.
isCancelled
Handle.isCancelled(self: HandleInternal) → booleanReturns whether this task has been cancelled.
Errors
| Type | Description |
|---|---|
| "Parent scope is destroyed" | Thrown if the parent Scope was destroyed. |