We use cookies on this site to enhance your user experience

Teleport all players in the server

Teleport all players in the server

Sep 11 2018, 3:09 AM PST

This code sample is an example of how TeleportService/TeleportPartyAsync can be used to teleport a group of Player|Players.

In this case, all Player|Players will be teleported to the specified placeId as a party. The DataModel/JobId of the destination server is then printed.

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

local placeId = 0 -- replace
local playerList = Players:GetPlayers()

local success, result = pcall(function()
    return TeleportService:TeleportPartyAsync(placeId, playerList)

if success then
    local jobId = result
    print("Players teleported to "..jobId)