function Maid.__newindex(A,X,G)if Maid[X]~=nil then error(("\067\097\110\110\111\116 \117\115\101 \'\037\115\' \097\115 \097 \077\097\105\100 \107\101\121"):format(tostring(X)),2)end local l=A._tasks local T=l[X]if T==G then return end l[X]=G if T then if type(T)=="\102\117\110\099\116\105\111\110"then T()elseif type(T)=="\116\104\114\101\097\100"then local X if coroutine.running()~=T then X=pcall(function()task.cancel(T)end)end if not X then task.defer(function()task.cancel(T)end)end elseif typeof(T)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then T:Disconnect()elseif T.Destroy then T:Destroy()end end end

function Maid:__newindex(index, newTask)
	if Maid[index] ~= nil then
		error(("Cannot use '%s' as a Maid key"):format(tostring(index)), 2)
	end

	local tasks = self._tasks
	local oldTask = tasks[index]

	if oldTask == newTask then
        	return
	end

	tasks[index] = newTask

	if oldTask then
		if type(oldTask) == "function" then
			oldTask()
		elseif type(oldTask) == "thread" then
			local cancelled
			if coroutine.running() ~= oldTask then
				cancelled = pcall(function()
					task.cancel(oldTask)
				end)
			end

			if not cancelled then
				task.defer(function()
					task.cancel(oldTask)
				end)
			end
		elseif typeof(oldTask) == "RBXScriptConnection" then
			oldTask:Disconnect()
		elseif oldTask.Destroy then
			oldTask:Destroy()
		end
	end
end
