local J={}local h={}local g=function()for J,h in J do for J,h in h do if typeof(h)=="\073\110\115\116\097\110\099\101"then h:Destroy()elseif type(h)=="\116\097\098\108\101"then if h._is_spring or h._is_tween or h._is_loop then h:DisconnectAll()elseif h._is_signal then h:Disconnect()elseif h._is_new then h:Cleanup()end else pcall(function()h:Disconnect()end)end end end for J,h in h do h.Cleanup()end end local r=function(...)for h,g in{...}do table.insert(J,g)end end local C=function(J)h=J end return{g,r;C}
local Created = {}
local Scopes = {}

local Cleanup = function()
	for _, list in Created do
		for _, v in list do
			if typeof(v) == "Instance" then
				v:Destroy()
			elseif type(v) == "table" then
				if v._is_spring or v._is_tween or v._is_loop then
					v:DisconnectAll()
				elseif v._is_signal then
					v:Disconnect()
				elseif v._is_new then
					v:Cleanup()
				end
			else
				pcall(function()
					v:Disconnect()
				end)
			end
		end
	end

	for _, v in Scopes do
		v.Cleanup()
	end
end

local SetCreated = function(...)
	for _, v in { ... } do
		table.insert(Created, v)
	end
end

local SetScopes = function(ScopeList)
	Scopes = ScopeList
end

return {
	Cleanup,
	SetCreated,
	SetScopes,
}
