I am creating an Experience with a Starting Place and multiple other Places.
I am confused about TeleportAsync.
Imagine you join the game with a friend.
Your friend goes to Place A.
You go to Place B.
Then you decide to meet back up at the Starting Place.
It doesn’t look like TeleportAsync actually works like that.
Right now, it looks like Roblox sends players to whatever server is open. So unless I teleport as part of a group with my friend we would go to different servers.
I want Experiences/Places to work the same as a single Experience with multiple locations/maps.
Am I just not getting it?
Does Roblox keep an Experience and all its Places running on one server?
Creating your own custom system to get a player’s username and letting a player teleport based on the username would be best.
An example of this would be in Plane Crazy. If you go into the gamemodes menu there is a text box that lets you type in a player’s username to go to their server.
I was just reading about GetPlayerPlaceInstanceAsync.
It looks like it might be what I am looking for.
There is a sample script that uses player.FollowUserID. From docs:
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
-- Is this player following anyone?
local followId = player.FollowUserId
-- If so, find out where they are
if followId and followId ~= 0 then
local _currentInstance, _errorMessage, placeId, jobId
local success, errorMessage = pcall(function()
-- followId is the user ID of the player that you want to retrieve the place and job ID for
_currentInstance, _errorMessage, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
if success then
-- Teleport player
TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
else
warn(errorMessage)
end
else
warn("Player " .. player.UserId .. " is not following another player!")
end
end)
It’s all over my head at the moment. I will keep reading.
This function allows you to get the place id and job id of the server another player is in. It basically tells you what server an inputted player is in, which you can use to teleport another player to the same server.
You might need to use something like the messaging service to have each server have a map of where players are. (Basically a server list with what players are in each server.) Then you could use that map to automatically teleport the players to a server with their friends.
I am curious if Roblox automatically teleports players to servers with their friends when the Teleport/TeleportAsync functions are called. If Roblox does, the problem might be that your servers aren’t configured to have extra slots.