How to teleport to specific server

Hi, i was trying to add more places to my game and i had an idea,
i want two places, one will be the starter and when the players join it will be teleported to the second place, i want to have a 3x3 maps(grid) in the second place but, how can i do this? I think adding a tag to the servers but i dont know how and how can i send the data

(Srry if my english is bad)

3 Likes

Use the TeleportService by getting it from game: game:GetService(“TeleportService”) and then use the TeleportAsync function, to teleport the player to a placeid.

2 Likes

yes i know but how i exactly teleport to for an example the zone 5

1 Like

Wait, do you mean teleport the player to a place inside the game or to a server, placeid?

1 Like

i want to add 9 zones in a one place, when you join the game u will be automatically teleported to the server with the correct zone, but how can i add a tag to the server or something to know what zone its

1 Like

You can create a table to store the 9 zones. Then, use that table to teleport the player to the correct zone. To determine the player’s current zone, you can utilize the workspace by adding a part or value where the zone name is stored. This allows you to retrieve the player’s current zone.

2 Likes

but how can i get the zone server, if i only teleport the player to the zone the player will appear in a random zone

Something like the game “waste of space”

Uh, can i do this using a datastore and saving all servers there?

You can create a server with TeleportServer:ReserveServer() and teleport to the code that is returned by that function.

Of course! You can use the DataStore.

how? can i do this and later if other player wants to join to the same zone he will can?

Yeah, they can teleport to the same server using the code.

but there will not be only one server with ej zone 1, there can be more servers with zone 1

So you want different servers to have different zones? One way of doing this is saving what zone each server has in a datastore.

1 Like

yeah im doing this but how can i teleport the player to a server with a low players or how can i get the player count of a server with the game.JobId

When a player joins the server you can update a datastore.

i was trying that, and i first add this to datastore:

table.insert(value, {game.JobId, 1})

but when the server closes i do this:

local tt = table.find(value, ServerId)
if tt then
	table.remove(value, tt)
end

but it dont works because it cant find the serverid so what can i do?

ill try using a loop(i think this isnt efficient)