function ServiceBag.Start(Z)assert(Z._serviceTypesToStart,"\065\108\114\101\097\100\121 \115\116\097\114\116\101\100")assert(not Z._initializing,"\083\116\105\108\108 \105\110\105\116\105\097\108\105\122\105\110\103")while next(Z._serviceTypesToStart)do local y=table.remove(Z._serviceTypesToStart)local F=assert(Z._services[y],"\078\111 \115\101\114\118\105\099\101")local g=Z:_getServiceName(y)if F.Start then local Z task.spawn(function()debug.setmemorycategory(g)Z=coroutine.running()F:Start()end)local y=coroutine.status(Z)=="\100\101\097\100"if not y then error(("\083\116\097\114\116\105\110\103 \115\101\114\118\105\099\101 \037\113 \121\105\101\108\100\101\100"):format(g))end end end Z._serviceTypesToStart=nil end function ServiceBag._getServiceName(y,Z)local F pcall(function()F=Z.ServiceName end)if type(F)=="\115\116\114\105\110\103"then return F end return tostring(Z)end
--[=[
	Starts the service bag and all services
]=]
function ServiceBag:Start()
	assert(self._serviceTypesToStart, "Already started")
	assert(not self._initializing, "Still initializing")

	while next(self._serviceTypesToStart) do
		local serviceType = table.remove(self._serviceTypesToStart)
		local service = assert(self._services[serviceType], "No service")
		local serviceName = self:_getServiceName(serviceType)

		if service.Start then
			local current
			task.spawn(function()
				debug.setmemorycategory(serviceName)
				current = coroutine.running()
				service:Start()
			end)

			local isDead = coroutine.status(current) == "dead"
			if not isDead then
				error(("Starting service %q yielded"):format(serviceName))
			end
		end
	end

	self._serviceTypesToStart = nil
end

function ServiceBag:_getServiceName(serviceType)
	local serviceName
	pcall(function()
		serviceName = serviceType.ServiceName
	end)
	if type(serviceName) == "string" then
		return serviceName
	end

	return tostring(serviceType)
end
