I’ve decided to ask for help on dev forums as this is the best place for solutions.
On the regular help page, explanations are mostly focused on everyone in the game. What if we wanted to teleport specific people who have a created BoolValue inside of them set to true?
For teleporting single players or groups of people to reserved servers, use TeleportToPrivateServer.
You’ll need to provide several parameters, one of them being a list of player objects to teleport. Simply loop through all players before teleporting and add players with the BoolValue to a table. The provide that table when calling TeleportService:TeleportToPrivateServer!
The only way to move players to a private server is with TeleportToPrivateServer, as mentioned by the above post. This means that you are going to have to collect a table of players who match your criteria and pass that as the Players variable. Luckily, TeleportToPrivateServer supports multi-person teleporting.
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local function playerAllowedToTeleport(player)
local access = player:FindFirstChild("QueueTP")
if access and access:IsA("BoolValue") then
return access.Value
end
return false
end
local queue = {} do
for _, Player in pairs(Players:GetPlayers()) do
if playerAllowedToTeleport(player) then
table.insert(Player, queue)
end
end
end
TeleportService:TeleportToPrivateServer(placeId, reservedAccessCode, players)
For teleporting a single player, just make a new table with that player as the only entry.
Before you do that, made a slight correction to return the value of the ValueObject for more precise vetting. Just returning QueueTP would make the code check if QueueTP exists under the player and allow them to go if it’s there. Checking its value ensures that even if they have the object, it’ll only permit a teleport when the value is set to true.
This code also has to be edited in different mannerisms, but you probably already know that. Inserting this raw would just teleport everyone immediately at runtime.
PlaceId is a literal term for the target place. Those are the numbers after /games/ in your URL bar. ReservedAccessCode is what is returned from using ReserveServer. Players is a table of players who are intended to be teleported to the target place, represented by queue in my code.