Convert table into players

I have a global matchmaking system, and it uses a table and I wan’t to teleport all players that were in the queue to the SAME server. When I tested, each player got sent to their own server. In my script there is a table named queuedPlayers.

Though when I printed the table it just printed something like “table(randomletters)” and not the queued players. How would I fix this?

--Variables
local memoryStore = game:GetService("MemoryStoreService")
local queue = memoryStore:GetSortedMap("Queue")

local tpService = game:GetService("TeleportService")

local minimum = 1
local maximum = 1
 
local placeId = 12576175275
 
local re = game.ReplicatedStorage.MenuRemotes:WaitForChild("Queue")
 

function addToQueue(player)
    queue:SetAsync(player.UserId, player.UserId, 2592000)
end
 
function removeFromQueue(player)
    queue:RemoveAsync(player.UserId)
end
 
 

local cooldown = {}
 
re.OnServerEvent:Connect(function(player, inQueue)
    
    if cooldown[player] then return end
    cooldown[player] = true
    
    if inQueue == "IN QUEUE" then
        pcall(addToQueue, player)
		print("Player in Queue")
    elseif inQueue == "QUEUE" then
        pcall(removeFromQueue, player)
		print("Player not in queue")
    end
    
    wait(1)
    cooldown[player] = false
end)
 
 
game.Players.PlayerRemoving:Connect(removeFromQueue)
 
 

local lastOverMin = tick()
 
while wait(1) do
    
    local success, queuedPlayers = pcall(function()
        return queue:GetRangeAsync(Enum.SortDirection.Descending, maximum)
    end)
    
    if success then
        
        local amountQueued = 0
        
        for i, data in pairs(queuedPlayers) do
            amountQueued += 1
			print("Added Player to Queue")
			print(amountQueued)
        end
        
        if amountQueued < minimum then
			print("Not enough players")
            lastOverMin = tick()
        end
        
        local timeOverMin = tick() - lastOverMin
        
        if timeOverMin >= 15 or amountQueued == maximum then
            print("Queue Process Begin")
            for i, data in pairs(queuedPlayers) do  
                
                local userId = data.value
                local player = game.Players:GetPlayerByUserId(userId)
                
                if player then
					print("Player found in queue")
                    local success, err = pcall(function()
						print(queuedPlayers)

						player.FoundMatch.Value = true
							-- tried to fix the tp myself  here --
						--local code = tpService:ReserveServer(12576175275)
						--tpService:TeleportToPrivateServer(12576175275, code, {player})
						--tpService:TeleportAsync(placeId, {player})
						print("Teleporting")
                    end) 
                    
                    spawn(function()
                        if success then
                            wait(1)
                            pcall(function()
                                queue:RemoveAsync(data.key)
                            end)
                        end
                    end)
                end
            end
        end
    end
end

You can try TeleportPartyAsync

I just got this:

for i,v in pairs(queuedPlayers[1]) do
	print(v)
end

It prints the userID’s of the queued players, though now do I make a new table and put all the ids in it and then teleport the queued players?

game.Players:GetPlayers()

Iterate through it with the for loop, then add their userIds

for _,v in game.Players:GetPlayers() do
    print(v.UserId) -- should print each players UserId 

This really doesn’t help as I want to get a table of players that are in the queued players table and then use the new table to teleport all the players to a Reserved Server

Im not really sure why you would create an entirely new table consisting of the same values, you can just use table.clone() for that, or iterate through all the values and add the Keys from there.

Because am confused why it wont work when I do:
tpService:TeleportToPrivateServer(12576175275, code, queuedPlayers)

And then when I print what inside the table, it prints the userId’s, so why wouldn’t it teleport the players?

when i tried using queued players it didnt print anything and kept trying to teleport but it wouldnt telelport, what is causing this, the table has the user id’s of queued players

Im sorry, i dont understand what youre trying to achieve

It doesn’t matter anymore, I found a global match making module instead of this script.