if not RunService:IsRunning()then return function(N)return Promise.resolved(GetRemoteEvent(N))end elseif RunService:IsServer()then return function(N)return Promise.resolved(GetRemoteEvent(N))end else return function(N)assert(type(N)=="\115\116\114\105\110\103","\066\097\100 \110\097\109\101")local H=ReplicatedStorage:FindFirstChild(ResourceConstants.REMOTE_EVENT_STORAGE_NAME)if H then local W=H:FindFirstChild(N)if W then return Promise.resolved(W)end end return Promise.spawn(function(H,W)H(GetRemoteEvent(N))end)end end

if not RunService:IsRunning() then
	-- Handle testing
	return function(name)
		return Promise.resolved(GetRemoteEvent(name))
	end
elseif RunService:IsServer() then
	return function(name)
		return Promise.resolved(GetRemoteEvent(name))
	end
else -- RunService:IsClient()
	return function(name)
		assert(type(name) == "string", "Bad name")

		local storage = ReplicatedStorage:FindFirstChild(ResourceConstants.REMOTE_EVENT_STORAGE_NAME)
		if storage then
			local obj = storage:FindFirstChild(name)
			if obj then
				return Promise.resolved(obj)
			end
		end

		return Promise.spawn(function(resolve, _)
			resolve(GetRemoteEvent(name))
		end)
	end
end
