Queueing system no idea how to fix

ok so I am a novice dev and I really just got this from a free model, but the thing is, all queue systems I find (+ no one has documented this) when two people make different queues and get sent into the game those 2 people (in seperate servers) get sent into one server in the game instead of them going into a game solo/with there party…

how in the world do I fix this?

1 Like

By rewriting the code to send them to individual servers if I understand your issue.

2 Likes

at beginning I said I dont know how to program… so uhhhh I know its rude but I could pay you (200 robux) to fix this code for me… if you could for free/paid please let me know.

2 Likes

Could you send the script?

I might be able to fix it.

2 Likes

sure here,

lemme just sorta set the stage so u know where everything is

in replicated storage theres parties RS folder and a event named “RE”

in server script service theres this script
'----------------------------------------------------------CONFIGURATION---------------------------------------------------------
local placeId = 12334067852 --The ID of the place to teleport to

local minQueue = 1 --Minimum amount of players needed to be teleported to the place
local maxQueue = 50 --Maximum amount of players that can be queued in the same lobby
local timeAfterMin = 20 --Time allowed for more players to enter the queue once the minimum amount of queued players is reached

local minMembers = 1 --Minimum players needed to queue
local maxMembers = 12 --Maximum players allowed in one party

local rs = game.ReplicatedStorage:WaitForChild(“PartyRS”)
local re = rs:WaitForChild(“RE”)
local parties = rs:WaitForChild(“Parties”)

local tps = game:GetService(“TeleportService”)

local ms = game:GetService(“MemoryStoreService”)
local queue = ms:GetSortedMap(“QueueStore”)

function findParty(plr)

for i, party in pairs(parties:GetChildren()) do
	for x, member in pairs(party.Members:GetChildren()) do

		if member.Name == plr.Name then
			return party
		end
	end
end

end

function joinParty(plr, party)
leaveParty(plr)

if party and #party.Members:GetChildren() < party.MaximumMembers.Value then
	local membersFolder = party.Members

	local memberValue = Instance.new("StringValue")
	memberValue.Name = plr.Name
	memberValue.Parent = membersFolder

	re:FireClient(plr, "JOIN", party)
end

end

function leaveParty(plr)

local currentParty = findParty(plr)

if currentParty then
	local members = currentParty.Members:GetChildren()

	local memberValue = currentParty.Members[plr.Name]
	table.remove(members, table.find(members, memberValue))

	if #members > 0 then
		if memberValue:FindFirstChild("Leader") then
			local newLeader = members[Random.new():NextInteger(1, #members)]
			memberValue.Leader.Parent = newLeader

			currentParty.Name = newLeader.Name .. "'s party"
		end

		memberValue:Destroy()
	else
		currentParty:Destroy()
	end

	re:FireClient(plr, "LEAVE")
end

end

game.Players.PlayerRemoving:Connect(leaveParty)

re.OnServerEvent:Connect(function(plr, instruction, data)

if instruction == "CREATE" then
	if data and tonumber(data) and tonumber(data) >= minMembers and tonumber(data) <= maxMembers then

		leaveParty(plr)

		local newParty = Instance.new("Folder")
		local partyName = plr.Name .. "'s party"
		newParty.Name = partyName

		local maxValue = Instance.new("IntValue")
		maxValue.Name = "MaximumMembers"
		maxValue.Value = data
		maxValue.Parent = newParty

		local membersFolder = Instance.new("Folder")
		membersFolder.Name = "Members"
		membersFolder.Parent = newParty

		local partyActive = true
		local function updateQueue()
			queue:RemoveAsync(partyName)

			if newParty:FindFirstChild("IN QUEUE") and partyActive then
				local members = {}
				for i, member in pairs(membersFolder:GetChildren()) do
					if game.Players:FindFirstChild(member.Name) then
						table.insert(members, game.Players[member.Name].UserId)
					end
				end

				queue:SetAsync(partyName, members, 2592000)
			end
		end

		membersFolder.ChildAdded:Connect(updateQueue)
		membersFolder.ChildRemoved:Connect(updateQueue)

		newParty.Destroying:Connect(function()
			partyActive = false
			queue:RemoveAsync(partyName)
		end)

		local memberValue = Instance.new("StringValue")
		memberValue.Name = plr.Name
		local leaderValue = Instance.new("StringValue")
		leaderValue.Name = "Leader"
		leaderValue.Parent = memberValue
		memberValue.Parent = membersFolder

		newParty.Parent = parties

		re:FireClient(plr, "JOIN", newParty)
	end

elseif instruction == "JOIN" then
	if data and parties:FindFirstChild(data) then
		joinParty(plr, parties[data])
	end

elseif instruction == "LEAVE" then
	leaveParty(plr)

elseif instruction == "KICK" then
	local plrToKick = data and game.Players:FindFirstChild(data)
	if plrToKick then

		local currentParty = findParty(plr)
		if currentParty and currentParty.Members[plr.Name]:FindFirstChild("Leader") then

			local currentPartyOfPlrToKick = findParty(plrToKick)
			if currentPartyOfPlrToKick and currentParty == currentPartyOfPlrToKick then
				leaveParty(plrToKick)
			end
		end
	end

elseif instruction == "QUEUE" then
	local currentParty = findParty(plr)

	local currentLeader = nil
	for i, member in pairs(currentParty.Members:GetChildren()) do
		if member:FindFirstChild("Leader") then
			currentLeader = member.Name
		end
	end

	if currentLeader == plr.Name and #currentParty.Members:GetChildren() >= minMembers then

		local inQueue = currentParty:FindFirstChild("IN QUEUE")

		if inQueue then
			queue:RemoveAsync(currentParty.Name)
			inQueue:Destroy()

		else
			local queueValue = Instance.new("IntValue")
			queueValue.Name = "IN QUEUE"
			queueValue.Parent = currentParty

			local members = {}
			for i, member in pairs(currentParty.Members:GetChildren()) do
				if game.Players:FindFirstChild(member.Name) then
					table.insert(members, game.Players[member.Name].UserId)
				end
			end
			queue:SetAsync(currentParty.Name, members, 2592000)

			local queueStart = os.time()
			while task.wait(1) do
				if queueValue then
					queueValue.Value = os.time() - queueStart
				else
					break
				end
			end
		end
	end
end

end)

local lastOverMin = tick()

while task.wait(1) do
local success, queuedData = pcall(function()
return queue:GetRangeAsync(Enum.SortDirection.Descending, maxQueue)
end)

if success then
	local queuedPlayers = 0
	local queuedParties = {}

	for i, data in pairs(queuedData) do
		local partyName = data.key
		local partyMembers = data.value
		local amountInParty = #partyMembers

		if queuedPlayers < maxQueue and queuedPlayers + amountInParty < maxQueue then

			queuedPlayers += amountInParty
			table.insert(queuedParties, partyName)
		end
	end

	if queuedPlayers < minQueue then
		lastOverMin = tick()
	end

	if tick() - lastOverMin >= timeAfterMin or queuedPlayers == maxQueue then

		for i, party in pairs(queuedParties) do  

			if parties:FindFirstChild(party) then
				local playersToTeleport = {}

				for x, member in pairs(parties[party].Members:GetChildren()) do
					table.insert(playersToTeleport, game.Players[member.Name])
				end

				tps:TeleportPartyAsync(placeId, playersToTeleport)
			end	
		end
	end
end

end`

in startergui theres a partygui and in that theres this script

local open = script.Parent:WaitForChild("Open")
local main = script.Parent:WaitForChild("Main"); main.Visible = false
local close = main:WaitForChild("Close")

local rs = game.ReplicatedStorage:WaitForChild("PartyRS")
local re = rs:WaitForChild("RE")
local parties = rs:WaitForChild("Parties")

local inParty = nil


function formatSeconds(totalSecs)
	
	local mins = tostring(math.floor(totalSecs / 60))
	local secs = tostring(totalSecs - (mins * 60))
	
	if string.len(mins) < 2 then
		mins = "0" .. mins
	end
	if string.len(secs) < 2 then
		secs = "0" .. secs
	end
	
	local formatted = mins .. ":" .. secs
	return formatted
end

function displayPage(requestedPage)
	for i, page in pairs(main:GetChildren()) do
		
		if page:IsA("Frame") then
			if page.Name == requestedPage.Name then
				page.Visible = true
			else
				page.Visible = false
			end
		end
	end
end

function getAvatar(playerName)
	if game.Players:FindFirstChild(playerName) then
		local uid = game.Players[playerName].UserId
		
		local image = game.Players:GetUserThumbnailAsync(uid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
		return image
	end
end

function displayParties()
	for i, partyFrame in pairs(main.PartiesPage.PartiesList:GetChildren()) do
		if partyFrame:IsA("Frame") then
			partyFrame:Destroy()
		end
	end
	
	local partyFrames = {}
	
	for i, party in pairs(parties:GetChildren()) do
		local partyFrame = script.PartyPageParty:Clone()
		table.insert(partyFrames, partyFrame)
		
		local function updatePartyFrame()			
			partyFrame:WaitForChild("NameLabel").Text = party.Name
			
			local leader = nil
			local members = {}
			
			for x, member in pairs(party.Members:GetChildren()) do
				if member:FindFirstChild("Leader") then
					leader = member.Name
				else
					table.insert(members, member.Name)
				end
			end
			
			partyFrame.Leader.Image = getAvatar(leader)
			
			table.sort(members, function(a, b)
				return a < b
			end)
			for x, member in pairs(members) do
				local memberImage = script.PartyPageMember:Clone()
				memberImage.Image = getAvatar(member)
				
				memberImage.Parent = partyFrame.MembersList
			end
			
			partyFrame.NumberOfMembers.Text = #party.Members:GetChildren() .. "/" .. party.MaximumMembers.Value
		end
		updatePartyFrame()
		party.Members.ChildAdded:Connect(updatePartyFrame)
		party.Members.ChildRemoved:Connect(updatePartyFrame)
		
		partyFrame.Join.MouseButton1Click:Connect(function()
			re:FireServer("JOIN", party.Name)
		end)
	end
	
	table.sort(partyFrames, function(a, b)
		return a.NameLabel.Text < b.NameLabel.Text
	end)
	for i, partyFrame in pairs(partyFrames) do
		partyFrame.Parent = main.PartiesPage.PartiesList
	end
	
	displayPage(main.PartiesPage)
end

function displayInParty(party)
	local partyFolder = typeof(party) == "string" and parties[party] or party
	
	local function updatePartyFrame()
		for i, memberFrame in pairs(main.InPartyPage.MembersList:GetChildren()) do
			if memberFrame:IsA("Frame") then
				memberFrame:Destroy()
			end
		end
		
		main.InPartyPage.NameLabel.Text = partyFolder.Name
		
		local leader = nil
		local members = {}
		
		for i, member in pairs(partyFolder.Members:GetChildren()) do
			if member:FindFirstChild("Leader") then
				leader = member.Name
			else
				table.insert(members, member.Name)
			end
		end
		table.sort(members, function(a, b)
			return a < b
		end)
		
		local leaderFrame = script.InPartyPageMember:Clone()
		leaderFrame.NameLabel.Text = leader
		leaderFrame.Avatar.Image = getAvatar(leader)
		leaderFrame.Kick.Visible = false
		
		leaderFrame.Parent = main.InPartyPage.MembersList
		
		if leader == game.Players.LocalPlayer.Name then
			leaderFrame.BackgroundColor3 = Color3.fromRGB(244, 236, 193)
			main.InPartyPage.Queue.BackgroundColor3 = Color3.fromRGB(67, 168, 87)
		else
			main.InPartyPage.Queue.BackgroundColor3 = Color3.fromRGB(172, 167, 165)
		end
		
		for i, member in pairs(members) do
			local memberFrame = script.InPartyPageMember:Clone()
			
			memberFrame.NameLabel.Text = member
			memberFrame.Avatar.Image = getAvatar(member)
			memberFrame.Leader.Visible = false
			
			if member == game.Players.LocalPlayer.Name then
				memberFrame.BackgroundColor3 = Color3.fromRGB(244, 236, 193)
			end
			
			if leader == game.Players.LocalPlayer.Name then
				memberFrame.Kick.Visible = true
				
				memberFrame.Kick.MouseButton1Click:Connect(function()
					re:FireServer("KICK", member)
				end)
			end
			
			memberFrame.Parent = main.InPartyPage.MembersList
		end
	end
	updatePartyFrame()
	party.Members.ChildAdded:Connect(updatePartyFrame)
	party.Members.ChildRemoved:Connect(updatePartyFrame)
	
	displayPage(main.InPartyPage)
	
	while inParty == party do
		if party:FindFirstChild("IN QUEUE") then
			main.InPartyPage.Queue.Text = formatSeconds(party["IN QUEUE"].Value)
			
		else
			main.InPartyPage.Queue.Text = "Queue"
		end
		task.wait(0.2)
	end
end

function displayCreateParty()
	displayPage(main.CreatePage)
	
	main.CreatePage.MaxMembers.Text = ""
end


open.MouseButton1Click:Connect(function()
	
	if main.Visible == false then
		main.Visible = true
		
		if inParty then
			displayInParty(inParty)
		else
			displayParties()
		end
		
	else
		main.Visible = false
	end
end)
close.MouseButton1Click:Connect(function()
	main.Visible = false
end)


main.PartiesPage.Create.MouseButton1Click:Connect(function()
	displayCreateParty()
end)

main.CreatePage.Back.MouseButton1Click:Connect(function()
	displayParties()
end)

main.CreatePage.Create.MouseButton1Click:Connect(function()
	local maxMembers = tonumber(main.CreatePage.MaxMembers.Text)
	if maxMembers then
		
		re:FireServer("CREATE", maxMembers)
	end
end)


main.InPartyPage.Leave.MouseButton1Click:Connect(function()
	re:FireServer("LEAVE")
end)

main.InPartyPage.Queue.MouseButton1Click:Connect(function()
	re:FireServer("QUEUE")
end)


re.OnClientEvent:Connect(function(instruction, party)
	
	if instruction == "JOIN" then
		inParty = party
		displayInParty(party)
		
	elseif instruction == "LEAVE" then
		inParty = nil
		displayParties()
	end
end)
`

Sorry for the late reply but heres the script:

if success then
	local queuedPlayers = 0
	local queuedParties = {}

	for i, data in pairs(queuedData) do
		local partyName = data.key
		local partyMembers = data.value
		local amountInParty = #partyMembers

		if queuedPlayers < maxQueue and queuedPlayers + amountInParty < maxQueue then

			queuedPlayers += amountInParty
			table.insert(queuedParties, partyName)
		end
	end

	if queuedPlayers < minQueue then
		lastOverMin = tick()
	end

	if tick() - lastOverMin >= timeAfterMin or queuedPlayers == maxQueue then

		for i, party in pairs(queuedParties) do  

			if parties:FindFirstChild(party) then
				local playersToTeleport = {}

				for x, member in pairs(parties[party].Members:GetChildren()) do
					table.insert(playersToTeleport, game.Players[member.Name])
				end

	local server =  tps:ReserveServer(placeId)
	local options = Instance.new("TeleportOptions")
	options.ReservedServerAccessCode = server

				tps:TeleportPartyAsync(placeId, playersToTeleport,options)
			end	
		end
	end
end

I believe this will work now.

Explanation:

Basically what I did is before you teleport the players you need to reserve a server for them so no one else can join. Then you can teleport them.

which script is this? the one I said goes into startergui or serverscriptservice also tysm

It’s the last serverscriptservice script you sent.

where do I put it, can youcombine it with the serverscript service script? (it looks a lil too small to replace the whole serverscriptservice script) so where would it go/could u show me?

Sure.

Just paste this:

	local server =  tps:ReserveServer(placeId)
	local options = Instance.new("TeleportOptions")
	options.ReservedServerAccessCode = server

above the:

tps:TeleportPartyAsync(placeId, playersToTeleport)

line

and also replace it with:

tps:TeleportPartyAsync(placeId, playersToTeleport,options)

oh uhhh… I did a test… we get sent into same server still (tested friended and unfriended)

(triple checked, game is saved script is done the way u did and its all good)

the method u gave me

Sure.

Just paste this:

	local server =  tps:ReserveServer(placeId)
	local options = Instance.new("TeleportOptions")
	options.ReservedServerAccessCode = server

above the:

tps:TeleportPartyAsync(placeId, playersToTeleport)

line

and also replace it with:

tps:TeleportPartyAsync(placeId, playersToTeleport,options)

the full script u gave me was way larger and this is fairly small… could u have missed something?

No I didn’t miss anything.

I can look at the script again if you want.

well its sending me into same game…

Try adding this line under the options.

options.ShouldReserveServer = true

If that doesn’t work try this:


	local server =  tps:ReserveServer(placeId)

tps:TeleportToPrivateServer(placeId,server,playersToTeleport)

instead of this:

	local server =  tps:ReserveServer(placeId)
	local options = Instance.new("TeleportOptions")
	options.ReservedServerAccessCode = server

tps:TeleportPartyAsync(placeId, playersToTeleport,options)

sorry to un solution (just say no if u cant and I will give solution back.)
but I have a level transport system (this queues into lvl 1 and u go into lvl2 later…)

I want it to be to where when all players reach a certain radius of it all of them get transported into another reserved server

local telePart = script.Parent
local TeleportService = game:GetService('TeleportService')
local placeID = (13050238945)
local canTeleport = true

local function otherGame(otherPart)

	local player = game.Players:FindFirstChild(otherPart.Parent.Name)

	if player and canTeleport then

		canTeleport = false

		TeleportService:Teleport(placeID, player)

		wait(0.3) --cooldown time

		canTeleport = true

	end

end

telePart.Touched:Connect(otherGame)

(if u have time make it to where after 1 minute of standing at exit it just transports all players but that would be ok if not)

if u can do this u would be chad :moyai: but just say no and I will give solution back :+1:

I mean I probably could do that but I don’t know how your game works. And right now I’m kinda sick so…

I’m really sorry but I can’t do it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.