Using ReservedServer() for making individual worlds for players

I want to use ReservedServer() to teleport players to an empty server every single time they press the button to do so, so that nobody ends up in the same server unless specified to join a certain server. Is there a way to make it so players always join a new server every time that happens?

1 Like

When you call the teleport, you need to add a teleport options parameter. The teleport options is an instance that you can set the ReservedServerAccessCode with the TeleportService:ReserviceServer(Id – The place id).

I do not know a lot about teleporting this is from a YouTube series I watched about making a tower defense game if you want to watch it just look up Gnome Code Tower Defense. The teleporting stuff is near the end of the series.

1 Like

Sorry if I’m misunderstanding, but are you saying that I can just call ReservedServer() with the placeId and people won’t end up all in the same instance?

1 Like

You can do that but by the knowledge I know I think you have to do that then set the teleport options with that.

Again, I am not entirely sure.

1 Like

I think I found GnomeCode’s video on it. It was the one on making the lobby for the game

1 Like

Yes, that is the one it was really helpful!

1 Like

Here’s what I’ve gotten so far: My only issue is that I can’t get the player to teleport. It throws the error: “Unable to cast value to Objects” on TeleportService:TeleportAsync(placeId, Player, Options)

game.ReplicatedStorage.Train.TeleportPlayer.OnServerEvent:Connect(function(Player)
	warn(Player.Name)
	local placeId = 13217679921
	local TeleportService = game:GetService("TeleportService")
	local Server = TeleportService:ReserveServer(placeId)
	local Options = Instance.new("TeleportOptions")
	Options.ReservedServerAccessCode = Server
	TeleportService:TeleportAsync(placeId, Player, Options)
end)

The player has to be put in a table {} because it expects a list.

1 Like

A example code

local playerlist = {}

function AddPlayerinList(player)
   table.insert(playerlist, player)
end

function RemovePlayerinList(player)
   table.remove(table.find(playerlist, player))
end
2 Likes

Both problems have been solved. Should I put the solution as the source of the info or the revised code I wrote?

1 Like

It’s up to you, honestly. But congrats!

2 Likes

Source of information:

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