local y=(game:GetService("\082\117\110\083\101\114\118\105\099\101")):IsServer()local w=game:GetService("\080\108\097\121\101\114\115")local s=require(script.Parent.Parent.Ser)local X={}X.__index=X function X.Is(y)return type(y)=="\116\097\098\108\101"and getmetatable(y)==X end function X.new()assert(y,"\082\101\109\111\116\101\083\105\103\110\097\108 \099\097\110 \111\110\108\121 \098\101 \099\114\101\097\116\101\100 \111\110 \116\104\101 \115\101\114\118\101\114")local w=setmetatable({_remote=Instance.new("\082\101\109\111\116\101\069\118\101\110\116")},X)return w end function X.Fire(w,y,...)w._remote:FireClient(y,s.SerializeArgsAndUnpack(...))end function X.FireAll(y,...)y._remote:FireAllClients(s.SerializeArgsAndUnpack(...))end function X.FireExcept(X,y,...)local H=s.SerializeArgs(...)for w,K in ipairs(w:GetPlayers())do if K~=y then X._remote:FireClient(K,s.UnpackArgs(H))end end end function X.Wait(y)return y._remote.OnServerEvent:Wait()end function X.Connect(w,y)return w._remote.OnServerEvent:Connect(function(w,...)y(w,s.DeserializeArgsAndUnpack(...))end)end function X.Destroy(y)y._remote:Destroy()y._remote=nil end return X



local IS_SERVER = game:GetService("RunService"):IsServer()

local Players = game:GetService("Players")
local Ser = require(script.Parent.Parent.Ser)

local RemoteSignal = {}
RemoteSignal.__index = RemoteSignal


function RemoteSignal.Is(object)
	return type(object) == "table" and getmetatable(object) == RemoteSignal
end


function RemoteSignal.new()
	assert(IS_SERVER, "RemoteSignal can only be created on the server")
	local self = setmetatable({
		_remote = Instance.new("RemoteEvent");
	}, RemoteSignal)
	return self
end


function RemoteSignal:Fire(player, ...)
	self._remote:FireClient(player, Ser.SerializeArgsAndUnpack(...))
end


function RemoteSignal:FireAll(...)
	self._remote:FireAllClients(Ser.SerializeArgsAndUnpack(...))
end


function RemoteSignal:FireExcept(player, ...)
	local args = Ser.SerializeArgs(...)
	for _,plr in ipairs(Players:GetPlayers()) do
		if plr ~= player then
			self._remote:FireClient(plr, Ser.UnpackArgs(args))
		end
	end
end


function RemoteSignal:Wait()
	return self._remote.OnServerEvent:Wait()
end


function RemoteSignal:Connect(handler)
	return self._remote.OnServerEvent:Connect(function(player, ...)
		handler(player, Ser.DeserializeArgsAndUnpack(...))
	end)
end


function RemoteSignal:Destroy()
	self._remote:Destroy()
	self._remote = nil
end


return RemoteSignal
