How to use TeleportService with reserved settings to other Place

Hi members,
I’m new to Roblox DevForm, I have a question about TeleportService. In my game, I have 4 Places. Two of them are SinglePlayer and MultiPlayer. All I want is to teleport a group of Players (specified) to one MultiPlayer Place to have a gamePlay there. After game played there, they will return back and that server should be vanished/shutdown (No one should be able to join this server again). So, lets say 4 players were selected to teleport to have a match themselves (No other Player can join this server). Now I have made a research on Teleporting, but little confused on it. Which method would be the best for this case (“Reserved Server” or “Private Server”).
Please help to get solve this barrier.

1 Like

You should use ReservedServer and to create ReservedServer there is 2 ways :

3 Likes

Okay,
Point 1- Creating code using TeleportService:ReserveServer(placeid) and teleporting to there, Would it only available for these specific players? And I also don’t want them to join this server again if they left (assuming gameplay isn’t completed). And Can I use same code to teleport different batch of players to same Place (but on different server obviously).
Point 2- How can I use TeleportAsync method to achieve same?

Thanks for reply

1 Like

they can be only accessed using :TeleportToPrivateServer as mentioned in the documentation

yes, as long as you teleport the group of players to the same reserved server respectively

not quite sure but, they shouldn’t be redirected to the server upon rejoining

yeah?

1 Like

Point 2 to achieve the same way you should configure your teleport options instance and set TeleportOptions.ShouldReserveServer to true

1 Like

Don’t know why but I’m keep getting below error.

Here’s the chunk of the code that I’m using to Teleport:-

--Server-Side script
function TeleportManager:TeleportToServerWithOptions(players : table, placeDetails, teleportOptions:TeleportOptions)
	warn("Teleporitng to :", placeDetails.Name)
	print("Players:",players)
	print("TeleportOptions:",teleportOptions)
	
	Teleport:TeleportAsync(placeDetails.PlaceId, players, teleportOptions) --Getting error at this line
end

-->>Other Server-Side script

	local options = Instance.new("TeleportOptions")
	options.ShouldReserveServer = true
	options:SetTeleportData(mapDetails) --mapDetails (table) that also to be send to that place
	
	TeleportManager:TeleportToServerWithOptions(players, ConstantsData.TeleportPlaces.MultiPlayer, options)

I know Teleportation doesn’t work in Studio. But this isn’t the error it gives usually.

1 Like

It is the error it gives test it in game not in studio

1 Like

You are right. Got Teleported in Player. Thanks

And as you can see the code, is this right way to do?

Yes it write in the good way everything good

1 Like

Thanks @fouroul94 for support,
In the final, I have done the below.

--function that teleports the Players to specified Place with reserved server (Only available to these player, doesn't matter the size of server. like if server size is 10 and 5 players have been sent using this method, than next batch of players would be sent to new server even if they could join this server.)

function TeleportManager:TeleportToServerWithOptions(players : table, placeDetails, teleportOptions:TeleportOptions)
	warn("Teleporitng to :", placeDetails.Name)
	print("Players:",players)
	print("TeleportOptions:",teleportOptions)
	
	Teleport:TeleportAsync(placeDetails.PlaceId, players, teleportOptions)
end

--Calling from another Server-Side script
function MultiPlayerTeleportService:TeleportToGame(players : table, mapDetails:ConstantsData.TrackDataType)
	warn("Teleporitng to :", mapDetails)
	
	local options = Instance.new("TeleportOptions")
	options.ShouldReserveServer = true --This would reserver the opening server. No other would be able to join this again
	options:SetTeleportData(mapDetails)
	
	TeleportManager:TeleportToServerWithOptions(players, ConstantsData.TeleportPlaces.MultiPlayer, options)
end

Hope this would also help anybody else.

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