How would I teleport every player using TeleportService?

I’m trying to make something where when someone clicks a button on the gui, it teleports everyone in the server. I’m trying to do this with remote events and putting the event in a server script. But it still only teleports 1 player. Here’s the server script I tried to use to teleport everyone:

    local TeleportService = game:GetService("TeleportService")

    local Place = REDACTED

    game.ReplicatedStorage.TeleportPlayers.OnServerEvent:Connect(function(player)

    TeleportService:Teleport(Place, player)

    end)

You can use TeleportService:TeleportPartyAsync which allows you to teleport a group of players to one server or TeleportService:TeleportToPrivateServer which teleports a group of players to a reserved server.

local TeleportService = game:GetService("TeleportService")
local Place = REDACTED
game.ReplicatedStorage.TeleportPlayers.OnServerEvent:Connect(function()
    local Players = game:GetService("Players"):GetPlayers()
    TeleportService:TeleportPartyAsync(Place, Players)
end)

Also if you haven’t already you should also setup TeleportService.TeleportInitFailed incase the teleport fails.

1 Like

instead of:
TeleportService:Teleport(Place, player)
try using:
for _, p in pairs(game.Players:GetPlayers())
TeleportService:Teleport(Place, p)
end

That still only teleports 1 player.

Thanks for the help! It worked!

1 Like

its a for loop so it should loop through the Players and teleport