Skip to main content

Cleaner

The Cleaner class provides a set of functions for cleaning up instances, and tables.

Functions

Cleanup

Cleaner.Cleanup(
itemany,--

The item to cleanup

itemTypestring?--

The item's type (impacts the cleanup function used)

) → ()

This function can be used to cleanup the passed item argument.

local Cleaner = require(game:GetService("ReplicatedStorage"):WaitForChild("Commons")).Cleaner
Cleaner.Cleanup(workspace.MyPart)

CleanupTable

Cleaner.CleanupTable(
table{[any]:any}--

The table to cleanup

) → ()

This function goes through a table, and deep cleans it (cleans up all values and nested tables).

local Cleaner = require(game:GetService("ReplicatedStorage"):WaitForChild("Commons")).Cleaner.Cleaner
local MyTable = {
	workspace.MyPart;
	{
		workspace.MyOtherPart;
	};
}

Cleaner.CleanupTable(MyTable) -- Will destroy Workspace.MyPart, and workspace.MyOther part, as well as clear up the table's metatables and contents
Show raw api
{
    "functions": [
        {
            "name": "Cleanup",
            "desc": "This function can be used to cleanup the passed item argument.\n```lua\nlocal Cleaner = require(game:GetService(\"ReplicatedStorage\"):WaitForChild(\"Commons\")).Cleaner\nCleaner.Cleanup(workspace.MyPart)\n```",
            "params": [
                {
                    "name": "item",
                    "desc": "The item to cleanup",
                    "lua_type": "any"
                },
                {
                    "name": "itemType",
                    "desc": "The item's type (impacts the cleanup function used)",
                    "lua_type": "string?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 42,
                "path": "src/Commons/Cleaner.luau"
            }
        },
        {
            "name": "CleanupTable",
            "desc": "This function goes through a table, and deep cleans it (cleans up all values and nested tables).\n\n```lua\nlocal Cleaner = require(game:GetService(\"ReplicatedStorage\"):WaitForChild(\"Commons\")).Cleaner.Cleaner\nlocal MyTable = {\n\tworkspace.MyPart;\n\t{\n\t\tworkspace.MyOtherPart;\n\t};\n}\n\nCleaner.CleanupTable(MyTable) -- Will destroy Workspace.MyPart, and workspace.MyOther part, as well as clear up the table's metatables and contents\n```",
            "params": [
                {
                    "name": "table",
                    "desc": "The table to cleanup",
                    "lua_type": "{[any]:any}"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 68,
                "path": "src/Commons/Cleaner.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Cleaner",
    "desc": "The Cleaner class provides a set of functions for cleaning up instances, and tables.",
    "source": {
        "line": 13,
        "path": "src/Commons/Cleaner.luau"
    }
}