function Maid.DoCleaning(F)local H=F.Tasks for F,T in pairs(H)do if typeof(T)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then H[F]=nil T:disconnect()end end local T,C=next(H)while C~=nil do H[T]=nil if type(C)=="\102\117\110\099\116\105\111\110"then C()elseif typeof(C)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then C:disconnect()elseif C.Destroy then C:Destroy()elseif C.destroy then C:destroy()elseif C.disconnect then C:disconnect()end T,C=next(H)end end Maid.Destroy=Maid.DoCleaning return Maid
--- Cleans up all tasks
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
