function Maid.DoCleaning(V)local n=V.Tasks for V,v in pairs(n)do if typeof(v)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then n[V]=nil v:disconnect()end end local v,S=next(n)while S~=nil do n[v]=nil if type(S)=="\102\117\110\099\116\105\111\110"then S()elseif typeof(S)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then S:disconnect()elseif S.Destroy then S:Destroy()elseif S.destroy then S:destroy()elseif S.disconnect then S:disconnect()end v,S=next(n)end end Maid.Destroy=Maid.DoCleaning return Maid

function Maid:DoCleaning()
	local Tasks = self.Tasks

	-- Disconnect all events first as we know this is safe
	for Index, Task in pairs(Tasks) do
		if typeof(Task) == "RBXScriptConnection" then
			Tasks[Index] = nil
			Task:disconnect()
		end
	end

	-- Clear out tasks table completely, even if clean up tasks add more tasks to the maid
	local Index, Task = next(Tasks)
	while Task ~= nil do
		Tasks[Index] = nil
		if type(Task) == "function" then
			Task()
		elseif typeof(Task) == "RBXScriptConnection" then
			Task:disconnect()
		elseif Task.Destroy then
			Task:Destroy()
		elseif Task.destroy then
			Task:destroy()
		elseif Task.disconnect then -- for pseudo RBXScriptConnection
			Task:disconnect()
		end
		Index, Task = next(Tasks)
	end
end
Maid.Destroy = Maid.DoCleaning

return Maid
