Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I teleport queue to a reserved server?

Asked by 5 years ago

I have a game and a queue script. I want the script to teleport players into one of the games that is part of the start place, but I want everyone who's in the same queue to go to the same server. I have the basic teleport code but I'm not sure how to reserve a server for a separate game. I have seen it in games like "Camping" and, "House Party" so I know that it's possible.

Here is the code

    if player_count == 4 then 
    print('teleporting')
    local queue1 = game.ReplicatedStorage.queue1:GetChildren()
local TS = game:GetService("TeleportService")
    for i,v in pairs(queue1) do
            local plr = game.Players:WaitForChild(v.Name)

TS:Teleport(3350448651,plr)

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Assuming you create a table with the players you want to teleport you can use ReservedServers to create a personal server for just this group of players.

local TS = game:GetService("TeleportService")

local players= {}

--add players to Players using table.insert()

local code = TS:ReserveServer(game.PlaceId) -- Returns a code

TS:TeleportToPrivateServer(game.PlaceId,code,players) -- Actually teleport the players
-- You could add extra arguments to this function: spawnName, teleportData and customLoadingScreen
0
Hi, I have seen this code before but I don't know how to reserve a server that isn't the same as the start place. I dont want a private server in the same game, I want one in one of my other places. mrorangethegamer 81 — 5y
0
@mrorangethegamer you can only use reserve servers using places under the same game DanzLua 2879 — 5y
0
@DanzLua My place is under the same game mrorangethegamer 81 — 5y
0
@DanzLua but I dont know how to reserve a server in the other place. mrorangethegamer 81 — 5y
View all comments (2 more)
0
@mrorangethegamer Instead giving ReserveServer() game.PlaceId give it the id of that place DanzLua 2879 — 5y
0
Also dont forget to change game.PlaceId in TeleportToPrivateServer() to that place too DanzLua 2879 — 5y
Ad

Answer this question