Players.Teleport
Declaration
Players.Teleport(number PlayerID, Vector3 Position)
Description
Teleports the specified player to Position
--Teleports the second player to the center of the map
local allPlayers = Players.GetAll();
local world = World.GetSettings();
Players.Teleport(allPlayers[2], V3(world.Width / 2, 1, world.Height / 2));
Declaration
Players.Teleport(number PlayerID, TargetPlayer Mode, Vector3 Origin, Vector3 Position)
Description
Teleports the specified player(s) to Position depending on the Mode. If using Mode set to Closest or Furthest, the Origin parameter will be used as the point of reference, otherwise Vector3.zero can be passed.
Check TargetPlayer for all possible Mode values.
--Teleports other team members of the specified player
local allPlayers = Players.GetAll();
Players.Teleport(allPlayers[1], TargetPlayer.OtherTeamMembers, Vector3.zero, V3(2, 1, 5));
--Teleports the furthest player from the provided point, PlayerID doesn't matter
local point = V3(2, 1, 3);
Players.Teleport(0, TargetPlayer.Furthest, point, V3(2, 1, 5));
Declaration
Players.Teleport(Dictionary<number> PlayerIDs, Vector3 Position)
Description
Teleports the specified players to Position.
--Teleports everyone to a certain position
local allPlayers = Players.GetAll();
Players.Teleport(allPlayers, V3(2, 1, 5));
--Teleports only the players that have enough bombs
local toTeleport = {};
for i, player in ipairs(allPlayers) do
if player.BombsTotal > 5 then
table.insert(toTeleport, player);
end
end
Players.Teleport(toTeleport, V3(2, 1, 5));
--Teleports only the first two players
Players.Teleport({allPlayers[1], allPlayers[2]}, V3(2, 1, 5));
Note
Player IDs must be whole numbers.
Keep in mind the Player IDs aren't necessarily ordered. Players can join and leave in the lobby, potentially several times, increasing their ID, which is why using Players.GetAll is advised if you want to target a player at a specific slot.
You can also pass Player objects instead of numbers as IDs.