Skip to content

Instantly share code, notes, and snippets.

@Fraktality
Last active April 9, 2024 00:22
Show Gist options
  • Save Fraktality/f0ab4ad950698e9f08bb01bea486845e to your computer and use it in GitHub Desktop.
Save Fraktality/f0ab4ad950698e9f08bb01bea486845e to your computer and use it in GitHub Desktop.
Some people just want to watch the world burn
local Dumpster = {} do
Dumpster.__index = Dumpster
local finalizers = setmetatable(
{
["function"] = function(item)
return item()
end,
["Instance"] = game.Destroy,
["RBXScriptConnection"] = Instance.new("BindableEvent").Event:Connect(function() end).Disconnect,
},
{
__index = function(self, className)
error(("Can't dump item of type '%s'"):format(className), 3)
end,
}
)
function Dumpster.new()
return setmetatable({}, Dumpster)
end
function Dumpster:dump(item)
self[item] = finalizers[typeof(item)]
return item
end
function Dumpster:burn()
for item, finalizer in pairs(self) do
finalizer(item)
end
table.clear(self)
end
end
return Dumpster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment