local C=2 local G=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local U=G:WaitForChild("\070\111\114\098\105\100\100\101\110")local H=U:WaitForChild("\077\117\108\116\105\112\108\097\121\101\114")local z=require(H:WaitForChild("\081\117\101\117\101"))local R=require(U:WaitForChild("\083\116\097\110\100\097\114\100"))local q=H:WaitForChild("\081\117\101\117\101")local B=q:WaitForChild("\115\105\103\110\097\108\115")local O=B:WaitForChild("\106\111\105\110")local T=B:WaitForChild("\108\101\097\118\101")local Z=B:WaitForChild("\116\111\067\108\105\101\110\116\077\097\116\099\104\073\110\102\111")local r=B:WaitForChild("\116\111\083\101\114\118\101\114\077\097\116\099\104\073\110\102\111")local function X(C) end local b=z.New()local function y()local G=z.Length(b)if C>G then return end local U={}for C=1,G,1 do U[C]=z.RemoveFront(b)end for C,G in pairs(U)do Z:FireClient(G,U)end r:Fire(U)X(U)end function joinRequest(C)z.AddToBack(b,C)y()end function leaveRequest(C)z.Remove(b,C)end O.OnServerInvoke=joinRequest T.OnServerInvoke=leaveRequest
-- Settings
local playersRequired = 2
-- Services
local rs = game:GetService("ReplicatedStorage")

local int_Forbidden 	= rs:WaitForChild("Forbidden")
local multiplayer 		= int_Forbidden:WaitForChild("Multiplayer")
local queueMOD 			= require(multiplayer:WaitForChild("Queue"))
local std 				= require(int_Forbidden:WaitForChild("Standard"))

local queueFOL 			= multiplayer:WaitForChild("Queue")
local signals 			= queueFOL:WaitForChild("signals")
local join 				= signals:WaitForChild("join")
local leave 			= signals:WaitForChild("leave")
local matchmade 		= signals:WaitForChild("toClientMatchInfo")
local server_matchmade 	= signals:WaitForChild("toServerMatchInfo")



local function MatchFound(players)
	
	--[[ ex. code (when match is found teleport the players)
	print(players)
	
	local destination = Vector3.new(0,0,0) -- can be a vector3, CFrame, part, or model
	
	for i, plr in pairs(players) do
		std.basic.Teleport(plr, destination, 1)
	end
	]]--
end








------------------------------------------------------------------------------
--FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN--
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN--
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN----FORBIDDEN--
------------------------------------------------------------------------------



local queue = queueMOD.New()


local function Matchmaking()
	
	local length = queueMOD.Length(queue)
	
	if playersRequired > length then return end
	
	local match = {}
	
	for i=1,length,1 do
		
		match[i] = queueMOD.RemoveFront(queue)
	end
	
	for i, plr in pairs(match) do
		matchmade:FireClient(plr, match)
	end
	
	server_matchmade:Fire(match)
	MatchFound(match)
end

function joinRequest(plr)
	
	queueMOD.AddToBack(queue, plr)
	
	Matchmaking()
end

function leaveRequest(plr)
	
	queueMOD.Remove(queue, plr)
end

join.OnServerInvoke = joinRequest
leave.OnServerInvoke = leaveRequest