Forest Logo
search
package_2

create-scope

By @sap0bombado

Roblox

Mirrored

create-scope

Resource cleanup. Track Instances, connections, threads, and functions, clean them all at once by calling scope().

Install

[dependencies]
createScope = "sap0bombado/create-scope@0.3.1"

API

createScope(size?, ...) -> (Scope, T...)

ParamTypeDescription
sizenumber?Initial capacity
...T...Initial items to track (returned as extra values)

Scope

Callable: scope(item) -> item tracks an item; scope() cleans up all items.

Cleans items by type: Instance (:Destroy), RBXScriptConnection (:Disconnect), function (call it), thread (task.cancel), table (tries common cleanup methods like :Destroy, :Disconnect, etc.).

Example

local scope = createScope()

local part = scope(Instance.new("Part"))
part.Parent = workspace

local conn = scope(RunService.Heartbeat:Connect(function(dt)
    print("Heartbeat", dt)
end))

scope(function()
    print("Custom cleanup")
end)

-- Clean everything
scope()

Package Details

Install command (Click to copy)


Version

0.3.1

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.