Skip to content

Clean

Recursively disposes a Cleanable, the same teardown that runs when a scope is destroyed. Call it to clean up something by hand. A Roblox Instance is Destroyed, an RBXScriptConnection is Disconnected, a suspended thread is cancelled, and a function is invoked. A table is cleaned by its Destroy/destroy/Disconnect/disconnect method if present, otherwise treated as a nested array and each element cleaned in turn. Errors during cleanup are caught and warned, never re-raised.

Open Documentation

Types

Cleanable type

luau
type Cleanable = () -> () | Instance | RBXScriptConnection | any | thread | { [number]: Cleanable }

Functions

Clean

luau
Clean(obj: Cleanable)