okay so, long story short i made a queue system…
When u touch a part it puts u in the queue table… when there are more than 1 player in the table it will run a function:
local function tpPlayers(player)
local server = tp:ReserveServer(7818885541)
tp:TeleportToPrivateServer(7818885541, server, {player})
end
the “player” is just the player on the table.
The thing works perfectly it teleports u and everything but it wont teleport them to the same server, how will i do that?
i tried doing an in pairs loop but it doesn’t work.
How would i approach this problem?
You might be able to use PrivateServerId with HttpService to teleport them to the same server. If this isn’t what you are going for then I’m not sure you explained it well enough. I haven’t personally used private servers but I’m going off of a guess.
You should pass an array of players to the function named “tpPlayers”, you can name the variable something like “players” (might be taken) or “playersToTp” etc. Then all you’ll need to do is pass that variable as an argument to the function, then inside the function “{player}” can be replaced with “playersToTp” or whatever the variable is named since the variable itself is a reference to an array of player objects. With this, all the players in the queue should be sent to the same server.
so, just get the table (which im expecting the script already has stored everyone in) and just make it an array or its already an array… i dont remember honestly
local queuePart = game.Workspace.Queue
local InQueue = {}
local tp = game:GetService("TeleportService")
local function tpPlayers(player)
local server = tp:ReserveServer(7818885541)
tp:TeleportToPrivateServer(7818885541, server, {player})
end
queuePart.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not table.find(InQueue, player) then
table.insert(InQueue, player)
if #InQueue > 1 then
wait(10)
for i, v in pairs(InQueue) do
tpPlayers(v)
print("Teleporting.. " .. v.Name)
end
end
end
end
end)
local queuePart = game.Workspace.Queue
local InQueue = {}
local tp = game:GetService("TeleportService")
local function tpPlayers(playerQueue)
local server = tp:ReserveServer(7818885541)
tp:TeleportToPrivateServer(7818885541, server, playerQueue)
end
queuePart.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not table.find(InQueue, player) then
table.insert(InQueue, player)
if #InQueue > 1 then
wait(10)
tpPlayers(InQueue)
print("Teleporting... " .. table.concat(InQueue, ", "))
end
end
end
end)