function Scheduler.AddItem(P,N)assert(AddItemTuple(P,N))local X=tick()+(N or 10)local d d=Heartbeat:Connect(function()if tick()>=X then d:Disconnect()if P then if P.Destroy then pcall(P.Destroy,P)elseif P.destroy then pcall(P.destroy,P)elseif P.Disconnect then pcall(P.Disconnect,P)elseif P.disconnect then pcall(P.disconnect,P)end end end end)return d end return Scheduler
--[[**
	This function allows the developer to schedule the removal of the object without yielding any code. It is the suggested alternative to Debris:AddItem, as this doesn't use the legacy scheduler and also supports tables with a Destroy / destroy method.

	@param [t:union<t:Instance, t:table, t:RBXScriptConnection, t:userdata>] Object The object to be added to destroy scheduler.
	@param [t:optional<t:numberMin<0>>] Lifetime The number of seconds before the object should be destroyed. Defaults to 10.
	@returns [void]
**--]]
function Scheduler.AddItem(Object, Lifetime)
	assert(AddItemTuple(Object, Lifetime))
	local ExecuteTime = tick() + (Lifetime or 10)
	local Connection

	Connection = Heartbeat:Connect(function()
		if tick() >= ExecuteTime then
			Connection:Disconnect()
			if Object then
				if Object.Destroy then
					pcall(Object.Destroy, Object)
				elseif Object.destroy then
					pcall(Object.destroy, Object)
				elseif Object.Disconnect then
					pcall(Object.Disconnect, Object)
				elseif Object.disconnect then
					pcall(Object.disconnect, Object)
				end
			end
		end
	end)

	return Connection
end

return Scheduler
