local m={}m.Connections={}m.LastIteration=nil m.Name="\077\097\110\097\103\101\114"local X={}X.Debug=false X.RunService="\083\116\101\112\112\101\100"local f=setmetatable({},{__index=function(m,X)m[X]=game:GetService(X)return m[X]end})function m.set(m)assert(typeof(m)=="\116\097\098\108\101","\091\077\065\078\065\071\069\082\093\058 \'\115\101\116\' \101\120\112\101\099\116\101\100 \100\105\099\116\105\111\110\097\114\121\044 \103\111\116 \'"..(typeof(m).."\'"))X.Debug=m.Debug or false X.RunService=m.RunService or"\083\116\101\112\112\101\100"end function m.wait(m)if m then local P=os.clock()while m>os.clock()-P do f.RunService[X.RunService]:Wait()end end return f.RunService[X.RunService]:Wait()end function m.wrap(m,...)assert(typeof(m)=="\102\117\110\099\116\105\111\110","\091\077\065\078\065\071\069\082\093\058 \'\119\114\097\112\' \111\110\108\121 \097\099\099\101\112\116\115 \102\117\110\099\116\105\111\110\115\044 \103\111\116 \'"..(typeof(m).."\'"))local X=coroutine.create(m)local f,P=coroutine.resume(X,...)if not f then local m=debug.traceback(X)error(P..("\n"..m))end end function m.spawn(m,...)assert(typeof(m)=="\102\117\110\099\116\105\111\110","\091\077\065\078\065\071\069\082\093\058 \'\115\112\097\119\110\' \111\110\108\121 \097\099\099\101\112\116\115 \102\117\110\099\116\105\111\110\115\044 \103\111\116 \'"..(typeof(m).."\'"))local P={...}local j j=f.RunService[X.RunService]:Connect(function()j:Disconnect()local f,q=pcall(function()return m(table.unpack(P))end)if not f and X.Debug then warn(q)end return end)end function m.loop(...)local m={...}local P,j do if typeof(m[1])=="\110\117\109\098\101\114"then P=m[1]j=m[2]else P=60 j=m[1]end end local q=.016666666666667 local n=0 local w w=f.RunService[X.RunService]:Connect(function(m)n=n+m while n>=q do n=n-q j()end end)return w end function m.delay(X,f,...)assert(typeof(X)=="\110\117\109\098\101\114"and typeof(f)=="\102\117\110\099\116\105\111\110","\091\077\065\078\065\071\069\082\093\058 \'\100\101\108\097\121\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \'"..(typeof(X)..("\' \097\110\100 \'"..(typeof(f).."\'"))))local P={...}m.wrap(function()local j=os.clock()while X>os.clock()-j do m.wait()end return m.wrap(f,table.unpack(P))end)end function m.garbage(X,f)assert(typeof(X)=="\110\117\109\098\101\114"and typeof(f)=="\073\110\115\116\097\110\099\101","\091\077\065\078\065\071\069\082\093\058 \'\103\097\114\098\097\103\101\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \'"..(typeof(X)..("\' \097\110\100 \'"..(typeof(Instance).."\'"))))m.wrap(function()local P=os.clock()while X>os.clock()-P do m.wait()end f:Destroy()end)end function m.retry(f,P,...)assert(typeof(f)=="\110\117\109\098\101\114"and typeof(P)=="\102\117\110\099\116\105\111\110","\091\077\065\078\065\071\069\082\093\058 \'\114\101\116\114\121\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \'"..(typeof(f)..("\' \097\110\100 \'"..(typeof(P).."\'"))))local j=os.clock()local q,n while not q and f>os.clock()-j do q,n=pcall(P,...)m.wait()end if not q and X.Debug then warn(n,debug.traceback())end return q,n end function m.Connect(P,f)assert(f~=nil,"\091\077\065\078\065\071\069\082\093\058 \'\067\111\110\110\101\099\116\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \102\117\110\099\116\105\111\110 \'"..(typeof(f).."\'"))local j={}function j.Disconnect(m)j=nil if typeof(f)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then f:Disconnect()elseif typeof(f)=="\116\097\098\108\101"then local m,P=pcall(function()f:Disconnect()end)if not m and X.Debug then warn("\091\077\065\078\065\071\069\082\093\058",P)end end f=nil setmetatable(j,{__index=function()error("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116 \116\111 \117\115\101 \100\101\115\116\114\111\121\101\100 \099\111\110\110\101\099\116\105\111\110")end,__newindex=function()error("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116 \116\111 \117\115\101 \100\101\115\116\114\111\121\101\100 \099\111\110\110\101\099\116\105\111\110")end})end function j.Fire(X,...)if typeof(f)=="\102\117\110\099\116\105\111\110"then return m.wrap(f,...)else warn("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116\101\100 \116\111 \099\097\108\108 \058\070\105\114\101 \111\110 \'"..(typeof(f).."\'"))end end return j end function m.ConnectKey(j,f,P)assert(f~=nil and P~=nil,"\091 \077\065\078\065\071\069\082\093\058 \'\067\111\110\110\101\099\116\075\101\121\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \107\101\121 \'"..(typeof(f)..("\' \097\110\100 \103\111\116 \102\117\110\099\116\105\111\110 \'"..(typeof(P).."\'"))))if not m.Connections[f]then m.Connections[f]={}end local q={}function q.Disconnect(j)if not m.Connections[f]then return end m.Connections[f][P]=nil if typeof(P)=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then P:Disconnect()elseif typeof(P)=="\116\097\098\108\101"then local m,f=pcall(function()P:Disconnect()end)if not m and X.Debug then warn("\091\077\065\078\065\071\069\082\093\058",f)end end P=nil setmetatable(q,{__index=function()error("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116 \116\111 \117\115\101 \100\101\115\116\114\111\121\101\100 \099\111\110\110\101\099\116\105\111\110")end,__newindex=function()error("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116 \116\111 \117\115\101 \100\101\115\116\114\111\121\101\100 \099\111\110\110\101\099\116\105\111\110")end})end function q.Fire(X,...)if typeof(P)=="\102\117\110\099\116\105\111\110"then return m.wrap(P,...)else warn("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116\101\100 \116\111 \099\097\108\108 \058\070\105\114\101 \111\110 \'"..(typeof(P).."\'"))end end m.Connections[f][P]=q return q end function m.FireKey(f,X,...)assert(X~=nil,"\091\077\065\078\065\071\069\082\093\058 \'\070\105\114\101\075\101\121\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \107\101\121 \'"..(typeof(X).."\'"))if m.Connections[X]then for m,X in pairs(m.Connections[X])do X:Fire(...)end end end function m.DisconnectKey(f,X)assert(X~=nil,"\091\077\065\078\065\071\069\082\093\058 \'\068\105\115\099\111\110\110\101\099\116\075\101\121\' \109\105\115\115\105\110\103 \112\097\114\097\109\101\116\101\114\115\044 \103\111\116 \107\101\121 \'"..(typeof(X).."\'"))if m.Connections[X]then for f,P in pairs(m.Connections[X])do P:Disconnect()m.Connections[X][f]=nil end m.Connections[X]=nil end end function m.Task(j,P)P=P or 60 assert(typeof(P)=="\110\117\109\098\101\114","\091\077\065\078\065\071\069\082\093\058 \084\097\115\107 \115\099\104\101\100\117\108\101\114 \111\110\108\121 \097\099\099\101\112\116\115 \110\117\109\098\101\114\115 \102\111\114 \102\114\097\109\101\115 \112\101\114 \115\101\099\111\110\100\044 \103\111\116 \'"..(typeof(P).."\'"))local q={}q.CodeQueue={}q.UpdateTable={}q.Enable=true q.Sleeping=true q.Paused=false q.UpdateTableEvent=nil local n=os.clock()m.wait()local function w()m.LastIteration=os.clock()for X=#q.UpdateTable,1,-1 do q.UpdateTable[X+1]=q.UpdateTable[X]>=m.LastIteration-1 and q.UpdateTable[X]or nil end q.UpdateTable[1]=m.LastIteration end local function h()q.UpdateTableEvent=f.RunService[X.RunService]:Connect(w)while true do if q.Sleeping then break end if not q:Enabled()then break end if P<0 then if#q.CodeQueue>0 then q.CodeQueue[1]()table.remove(q.CodeQueue,1)if not q:Enabled()then break end else q.Sleeping=true break end else local X=os.clock()-n>=1 and#q.UpdateTable or#q.UpdateTable/(os.clock()-n)if X>=P and os.clock()-q.UpdateTable[1]<1/P then if#q.CodeQueue>0 then q.CodeQueue[1]()table.remove(q.CodeQueue,1)if not q:Enabled()then break end else q.Sleeping=true break end elseif q:Enabled()then m.wait()end end end q.UpdateTableEvent:Disconnect()q.UpdateTableEvent=nil end function q.Enabled(m)return q.Enable end function q.Pause(m)q.Paused=true q.Sleeping=true local X=os.clock()-n>=1 and#q.UpdateTable or#q.UpdateTable/(os.clock()-n)return X end function q.Resume(m)if q.Paused then q.Paused=false q.Sleeping=false h()end local X=os.clock()-n>=1 and#q.UpdateTable or#q.UpdateTable/(os.clock()-n)return X end function q.Wait(X)while not q.Sleeping do m.wait()end local f=os.clock()-n>=1 and#q.UpdateTable or#q.UpdateTable/(os.clock()-n)return f end function q.Disconnect(m)q.Enable=false q:Pause()q.CodeQueue=nil q.UpdateTable=nil q.UpdateTableEvent:Disconnect()q:Wait()for m in pairs(q)do q[m]=nil end setmetatable(q,{__index=function()error("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116 \116\111 \117\115\101 \100\101\115\116\114\111\121\101\100 \116\097\115\107 \115\099\104\101\100\117\108\101\114")end,__newindex=function()error("\091\077\065\078\065\071\069\082\093\058 \065\116\116\101\109\112\116 \116\111 \117\115\101 \100\101\115\116\114\111\121\101\100 \116\097\115\107 \115\099\104\101\100\117\108\101\114")end})end function q.Queue(X,m)if not q.CodeQueue then return end q.CodeQueue[#q.CodeQueue+1]=m if q.Sleeping and not q.Paused then q.Sleeping=false h()end end return q end return m
--[[
	@Author: Gavin "Mullets" Rosenthal
	@Desc: a task manager with scheduling & coroutines
--]]

--[[
[DOCUMENTATION]:
	https://github.com/Mullets-Gavin/Manager
	Listed below is a quick glance on the API, visit the link above for proper documentation.
	
	... = parameters
	
	Manager.wait(time)
	Manager.set(dictionary)
	Manager.wrap(function,...)
	Manager.spawn(function,...)
	Manager.garbage(time,instance)
	Manager.delay(time,function,...)
	Manager.retry(time,function,...)
	
	event = Manager:Connect(function)
	event:Disconnect()
	event:Fire(...)
	
	event = Manager:ConnectKey(key,function)
	event:Disconnect()
	event:Fire(...)
	
	Manager:FireKey(key,...)
	Manager:DisconnectKey(key)
	
	event = Manager:Task([fps])
	event:Queue(function)
	event:Pause()
	event:Resume()
	event:Wait()
	event:Enabled()
	event:Disconnect()
	
[LICENSE]:
	MIT License

	Copyright (c) 2020 Mullet Mafia Dev

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
--]]

--// logic
local Manager = {}
Manager.Connections = {}
Manager.LastIteration = nil
Manager.Name = 'Manager'

local Settings = {}
Settings.Debug = false
Settings.RunService = 'Stepped'

--// services
local Services = setmetatable({}, {__index = function(cache, serviceName)
	cache[serviceName] = game:GetService(serviceName)
	return cache[serviceName]
end})

--// functions
--[[
	Variations of call:
	
	.set(properties)
	
	properties = {
		['Debug'] = bool
		['RunService'] = 'Stepped' or 'Heartbeat'
	}
--]]
function Manager.set(properties)
	assert(typeof(properties) == 'table',"[MANAGER]: 'set' expected dictionary, got '".. typeof(properties) .."'")
	
	Settings.Debug = properties['Debug'] or false
	Settings.RunService = properties['RunService'] or 'Stepped'
end

--[[
	Variations of call:
	
	.wait(time)
--]]
function Manager.wait(clock)
	if clock then
		local current = os.clock()
		
		while clock > os.clock() - current do
			Services['RunService'][Settings.RunService]:Wait()
		end
	end
	
	return Services['RunService'][Settings.RunService]:Wait()
end

--[[
	Variations of call:
	
	.wrap(function)
]]--
function Manager.wrap(code,...)
	assert(typeof(code) == 'function',"[MANAGER]: 'wrap' only accepts functions, got '".. typeof(code) .."'")
	
	local thread = coroutine.create(code)
    local ran,response = coroutine.resume(thread, ...)
   
   if not ran then
        local trace = debug.traceback(thread)
        error(response .. "\n" .. trace)
    end
end

--[[
	Variations of call:
	
	.spawn(function)
]]--
function Manager.spawn(code,...)
	assert(typeof(code) == 'function',"[MANAGER]: 'spawn' only accepts functions, got '".. typeof(code) .."'")
	
	local data = {...}
	local event; event = Services['RunService'][Settings.RunService]:Connect(function()
		event:Disconnect()
		
		local success,err = pcall(function()
			return code(table.unpack(data))
		end)
		
		if not success and Settings.Debug then
			warn(err)
		end
		
		return
	end)
end

--[[
	Variations of call:
	
	.loop(fps,code)
	.loop(code)
	
	Returns:
	
	RBXScriptSignal
--]]
function Manager.loop(...)
	local data = {...}
	local fps,code; do
		if typeof(data[1]) == 'number' then
			fps = data[1]
			code = data[2]
		else
			fps = 60
			code = data[1]
		end
	end
	
	local rate = 1/60
	local logged = 0
	local event; event = Services['RunService'][Settings.RunService]:Connect(function(delta)
		logged = logged + delta
		
		while logged >= rate do
			logged = logged - rate
			code()
		end
	end)
	
	return event
end

--[[
	Variations of call:
	
	.delay(time,function)
]]--
function Manager.delay(clock,code,...)
	assert(typeof(clock) == 'number' and typeof(code) == 'function',"[MANAGER]: 'delay' missing parameters, got '".. typeof(clock) .."' and '".. typeof(code) .."'")
	
	local data = {...}
	Manager.wrap(function()
		local current = os.clock()
		
		while clock > os.clock() - current do
			Manager.wait()
		end
		
		return Manager.wrap(code,table.unpack(data))
	end)
end

--[[
	Variations of call:
	
	.garbage(time,function)
]]--
function Manager.garbage(clock,obj)
	assert(typeof(clock) == 'number' and typeof(obj) == 'Instance',"[MANAGER]: 'garbage' missing parameters, got '".. typeof(clock) .."' and '".. typeof(Instance) .."'")
	
	Manager.wrap(function()
		local current = os.clock()
		
		while clock > os.clock() - current do
			Manager.wait()
		end
		
		obj:Destroy()
	end)
end

--[[
	Variations of call:
	
	.retry(timeout,function)
--]]
function Manager.retry(clock,code,...)
	assert(typeof(clock) == 'number' and typeof(code) == 'function',"[MANAGER]: 'retry' missing parameters, got '".. typeof(clock) .."' and '".. typeof(code) .."'")
	
	local current = os.clock()
	local success,response
	
	while not success and clock > os.clock() - current do
		success,response = pcall(code,...)
		Manager.wait()
	end
	
	if not success and Settings.Debug then
		warn(response,debug.traceback())
	end
	
	return success,response
end

--[[
	Variations of call:
	
	:Connect(function)
	:Connect(RBXScriptConnection)
	
	Returns:
	
	control = dictionary
	control:Fire(...)
	control:Disconnect()
]]--
function Manager:Connect(code)
	assert(code ~= nil,"[MANAGER]: 'Connect' missing parameters, got function '".. typeof(code) .."'")
	local control = {}
	
	function control:Disconnect()
		control = nil
		
		if typeof(code) == 'RBXScriptConnection' then
			code:Disconnect()
		elseif typeof(code) == 'table' then
			local success,err = pcall(function()
				code:Disconnect()
			end)
			if not success and Settings.Debug then
				warn('[MANAGER]:',err)
			end
		end
		
		code = nil
		setmetatable(control, {
			__index = function()
				error('[MANAGER]: Attempt to use destroyed connection')
			end;
			__newindex = function()
				error('[MANAGER]: Attempt to use destroyed connection')
			end;
		})
	end
	
	function control:Fire(...)
		if typeof(code) == 'function' then
			return Manager.wrap(code,...)
		else
			warn("[MANAGER]: Attempted to call :Fire on '".. typeof(code) .."'")
		end
	end
	
	return control
end

--[[
	Variations of call:
	
	:Connect(key,function)
	:Connect(key,RBXScriptConnection)
	:Connect(key,table)
	
	Returns:
	
	control = dictionary
	control:Fire(...)
	control:Disconnect()
]]--
function Manager:ConnectKey(key,code)
	assert(key ~= nil and code ~= nil,"[ MANAGER]: 'ConnectKey' missing parameters, got key '".. typeof(key) .."' and got function '".. typeof(code) .."'")
	if not Manager.Connections[key] then
		Manager.Connections[key] = {}
	end
	local control = {}
	
	function control:Disconnect()
		if not Manager.Connections[key] then return end
		Manager.Connections[key][code] = nil
		
		if typeof(code) == 'RBXScriptConnection' then
			code:Disconnect()
		elseif typeof(code) == 'table' then
			local success,err = pcall(function()
				code:Disconnect()
			end)
			if not success and Settings.Debug then
				warn('[MANAGER]:',err)
			end
		end
		
		code = nil
		setmetatable(control, {
			__index = function()
				error('[MANAGER]: Attempt to use destroyed connection')
			end;
			__newindex = function()
				error('[MANAGER]: Attempt to use destroyed connection')
			end;
		})
	end
	
	function control:Fire(...)
		if typeof(code) == 'function' then
			return Manager.wrap(code,...)
		else
			warn("[MANAGER]: Attempted to call :Fire on '".. typeof(code) .."'")
		end
	end
	
	Manager.Connections[key][code] = control
	return control
end

--[[
	Variations of call:
	
	:FireKey(key)
	:FireKey(key,parameters)
--]]
function Manager:FireKey(key,...)
	assert(key ~= nil,"[MANAGER]: 'FireKey' missing parameters, got key '".. typeof(key) .."'")
	
	if Manager.Connections[key] then
		for code,control in pairs(Manager.Connections[key]) do
			control:Fire(...)
		end
	end
end

--[[
	Variations of call:
	
	:DisconnectKey(key)
--]]
function Manager:DisconnectKey(key)
	assert(key ~= nil,"[MANAGER]: 'DisconnectKey' missing parameters, got key '".. typeof(key) .."'")
	
	if Manager.Connections[key] then
		for code,control in pairs(Manager.Connections[key]) do
			control:Disconnect()
			Manager.Connections[key][code] = nil
		end
		Manager.Connections[key] = nil
	end
end

--[[
	Variations of call:
	
	:Task([fps])
	
	Returns:
	
	control = dictionary
	control:Queue(function)
	control:Pause()
	control:Resume()
	control:Disconnect()
--]]
function Manager:Task(targetFPS)
	targetFPS = targetFPS or 60
	assert(typeof(targetFPS) == 'number',"[MANAGER]: Task scheduler only accepts numbers for frames per second, got '".. typeof(targetFPS) .."'")
	
	local control = {}
	control.CodeQueue = {}
	control.UpdateTable = {}
	control.Enable = true
	control.Sleeping = true
	control.Paused = false
	control.UpdateTableEvent = nil
	
	local start = os.clock()
	Manager.wait()
	
	local function Update()
		Manager.LastIteration = os.clock()
		for index = #control.UpdateTable,1,-1 do
			control.UpdateTable[index + 1] = ((control.UpdateTable[index] >= (Manager.LastIteration - 1)) and control.UpdateTable[index] or nil)
		end
		control.UpdateTable[1] = Manager.LastIteration
	end
	
	local function Loop()
		control.UpdateTableEvent = Services['RunService'][Settings.RunService]:Connect(Update)
		
		while (true) do
			if control.Sleeping then break end
			if not control:Enabled() then break end
			
			if targetFPS < 0 then
				if (#control.CodeQueue > 0) then
					control.CodeQueue[1]()
					table.remove(control.CodeQueue, 1)
					if not control:Enabled() then
						break
					end
				else
					control.Sleeping = true
					break
				end
			else
				local fps = (((os.clock() - start) >= 1 and #control.UpdateTable) or (#control.UpdateTable / (os.clock() - start)))
				if (fps >= targetFPS and (os.clock() - control.UpdateTable[1]) < (1 / targetFPS)) then
					if (#control.CodeQueue > 0) then
						control.CodeQueue[1]()
						table.remove(control.CodeQueue, 1)
						if not control:Enabled() then
							break
						end
					else
						control.Sleeping = true
						break
					end
				elseif control:Enabled() then
					Manager.wait()
				end
			end
		end
		
		control.UpdateTableEvent:Disconnect()
		control.UpdateTableEvent = nil
	end
	
	function control:Enabled()
		return control.Enable
	end
	
	function control:Pause()
		control.Paused = true
		control.Sleeping = true
		
		local fps = (((os.clock() - start) >= 1 and #control.UpdateTable) or (#control.UpdateTable / (os.clock() - start)))
		return fps
	end
	
	function control:Resume()
		if control.Paused then
			control.Paused = false
			control.Sleeping = false
			Loop()
		end
		
		local fps = (((os.clock() - start) >= 1 and #control.UpdateTable) or (#control.UpdateTable / (os.clock() - start)))
		return fps
	end
	
	function control:Wait()
		while not control.Sleeping do
			Manager.wait()
		end
		
		local fps = (((os.clock() - start) >= 1 and #control.UpdateTable) or (#control.UpdateTable / (os.clock() - start)))
		return fps
	end
	
	function control:Disconnect()
		control.Enable = false
		control:Pause()
		control.CodeQueue = nil
		control.UpdateTable = nil
		control.UpdateTableEvent:Disconnect()
		control:Wait()
		
		for index in pairs(control) do
			control[index] = nil
		end
		
		setmetatable(control, {
			__index = function()
				error('[MANAGER]: Attempt to use destroyed task scheduler')
			end;
			__newindex = function()
				error('[MANAGER]: Attempt to use destroyed task scheduler')
			end;
		})
	end
	
	function control:Queue(code)
		if not control.CodeQueue then return end
		control.CodeQueue[#control.CodeQueue + 1] = code
		
		if (control.Sleeping and not control.Paused) then
			control.Sleeping = false
			Loop()
		end
	end
	
	return control
end

return Manager