local O=game:GetService("\082\117\110\083\101\114\118\105\099\101")local D={}local g={}local Y=nil local function B()if#g==0 then Y=Y and Y:Disconnect()end for O,D in next,g do if os.clock()-D[2]>=D[1]then local Y=D[3]table.remove(g,O)Y()break end end end function D.AddTask(x,D,f)if Y==nil then Y=O.Stepped:Connect(B)end D=D or 0 f=f or function()print("\069\109\112\116\121 \067\097\108\108\098\097\099\107 \070\117\110\099\116\105\111\110")end local o=#g g[o+1]={D,os.clock(),f}end return D

local RunService = game:GetService("RunService")

local TaskScheduler = {}
local Cache = {}
local SteppedConnection = nil

local function OnStepped()
	if #Cache == 0 then 
		SteppedConnection = SteppedConnection and SteppedConnection:Disconnect() 
	end

	for Index, Queue in next, Cache do
		if os.clock() - Queue[2] >= Queue[1] then
			local Callback = Queue[3];
			table.remove(Cache, Index);
			Callback();
			break
		end
	end
end

function TaskScheduler:AddTask(Duration, Callback)

	if SteppedConnection == nil then
		SteppedConnection = RunService.Stepped:Connect(OnStepped)
	end

	Duration = Duration or 0
	Callback = Callback or function() print("Empty Callback Function") end

	--| Sort 
	local CacheSize = #Cache
	Cache[CacheSize + 1] = {Duration, os.clock(), Callback}
end

return TaskScheduler
