How would I go about teleporting 2-7 players to a temporary private server for a match?

I am making a game that takes two players and up to 5 spectators from a lobby place into the ingame place. I see that there’s a couple ways to go about putting players in private servers. I read that they create server codes for players to come back to but I only want these servers to be temporary for the matches.

I already have two players ready in the scripts, but I’m not sure of the best method to teleport them into a temporary private server for a match. I don’t need a whole script, but a general idea would help out.

Edit: I would also like to have these players return to the same lobby server after the match.

2 Likes

I think these can help you:

Since it’s a private server you shouldn’t worry about other players teleporting there as you decide which players can be teleported there.

Yeah, but since I want a temporary private server created for every new match, I’m not sure if that won’t hit a limit or anything, because the servers are assigned codes
Unless these private servers disappear when I need them to

They won’t hit a limit, they are exactly like normal servers except you choose which players will teleport there. Unless your game hits an extremely big amount of players, you shouldn’t worry about lag or some sort of limit.
Also I’ve seen that you asked to teleport them to the same lobby, unfortunately I don’t know how to do that so maybe someone else will be able to help you with it.

To teleport all the players use TeleportPartyAsync()
https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPrivateServe

1 Like

Check out TeleportService | Documentation - Roblox Creator Hub to teleport group of players to a server.
Here’s the one to teleport group players to reserved server: TeleportService | Documentation - Roblox Creator Hub.
Check out the documentation too: TeleportService | Documentation - Roblox Creator Hub.