How to forcefully teleport a player to an empty server when they join the game

I have a system that after certain event will happen, the game will kick you, setting this event value to 1, and each time a player joins, im checking if this value is equal to 1 to teleport them to an empty server, but I don’t know if you can do that in roblox (?), so I’m asking for help in here, hope somebody knows the solution!

TLTR: Player joins → tp them to an empty server

You can create a new server for a player with TeleportService:ReserveServer() and TeleportService:TeleportAsync() to teleport players to the reserved server.

wait, but how to reserver a server, documentation just says on how to check if the server is reserved or no

I understood that by using second function you can teleport player to reserved server, but once again, how to reserve a server lol :sob:

EDIT: here’s the answer How to use :ReserveServer() to make a lobby system?

Take a look at this code sample taken directly from the documentation:

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local code = TeleportService:ReserveServer(game.PlaceId)

local players = Players:GetPlayers()

TeleportService:TeleportToPrivateServer(game.PlaceId, code, players)
-- You could add extra arguments to this function: spawnName, teleportData and customLoadingScreen

Although you should use TeleportService:TeleportAsync() instead of TeleportService:TeleportToPrivateServer().

1 Like

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