local M=(require(script.Parent.loader)).load(script)local r=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local f=game:GetService("\082\117\110\083\101\114\118\105\099\101")local l=M("\082\101\115\111\117\114\099\101\067\111\110\115\116\097\110\116\115")if not f:IsRunning()then return function(M)local r=Instance.new("\082\101\109\111\116\101\069\118\101\110\116")r.Archivable=false r.Name="\077\111\099\107"..M return r end elseif f:IsServer()then return function(M)assert(type(M)=="\115\116\114\105\110\103","\066\097\100 \110\097\109\101")local f=r:FindFirstChild(l.REMOTE_EVENT_STORAGE_NAME)if not f then f=Instance.new("\070\111\108\100\101\114")f.Name=l.REMOTE_EVENT_STORAGE_NAME f.Archivable=false f.Parent=r end local Y=f:FindFirstChild(M)if Y then return Y end Y=Instance.new("\082\101\109\111\116\101\069\118\101\110\116")Y.Name=M Y.Archivable=false Y.Parent=f return Y end else return function(M)assert(type(M)=="\115\116\114\105\110\103","\066\097\100 \110\097\109\101")return(r:WaitForChild(l.REMOTE_EVENT_STORAGE_NAME)):WaitForChild(M)end end


local require = require(script.Parent.loader).load(script)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local ResourceConstants = require("ResourceConstants")

if not RunService:IsRunning() then
	return function(name)
		local event = Instance.new("RemoteEvent")
		event.Archivable = false
		event.Name = "Mock" .. name

		return event
	end
elseif RunService:IsServer() then
	return function(name)
		assert(type(name) == "string", "Bad name")

		local storage = ReplicatedStorage:FindFirstChild(ResourceConstants.REMOTE_EVENT_STORAGE_NAME)
		if not storage then
			storage = Instance.new("Folder")
			storage.Name = ResourceConstants.REMOTE_EVENT_STORAGE_NAME
			storage.Archivable = false
			storage.Parent = ReplicatedStorage
		end

		local event = storage:FindFirstChild(name)
		if event then
			return event
		end

		event = Instance.new("RemoteEvent")
		event.Name = name
		event.Archivable = false
		event.Parent = storage

		return event
	end
else -- RunService:IsClient()
	return function(name)
		assert(type(name) == "string", "Bad name")

		return ReplicatedStorage:WaitForChild(ResourceConstants.REMOTE_EVENT_STORAGE_NAME):WaitForChild(name)
	end
end
