I need this Teleport Code to Work

Here is my code.

local player = game.Players:GetPlayers()
local TeleportService = game:GetService("TeleportService")


TeleportService:Teleport(7905254789, player)

This is a normal script.

I want to make this script teleport all the players to the next Place

How do I do that

LargeHotDogs13

Always check the developer.roblox.com site!

2 Potential Things why it may not be working:

A - Turn on Third Party Teleports
image

B - I believe Teleport() only supports a single Player Instance, and not a table of Players

C - Thanks API, very helpful
image

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

for _, player in pairs(Players:GetPlayers()) do
     TeleportService:Teleport(7905254789, player)
end

If you’re going to teleport certain players, insert them into a table, and replace Players:GetPlayers() with the table name

1 Like

Third party teleports isn’t an answer. TeleportService:Teleport() can be used to teleport one player, but you can loop thru a table of players and teleport each individual one.

image

Still would’ve helped to say it anyways, but alright

@LargeHotDogs13 Also another slight reminder, but you can’t Teleport within Studio as you’ll need to head to the ROBLOX Client to do it instead

Yes I tried that. Imagine if you could you could copy any game.

While this works, I suggest using TeleportAsync (it teleports an array of players and allows more teleport options)

local TeleportService = game:GetService('TeleportService')
-- OPTIONAL // local TeleportOptions = Instance.new('TeleportOptions')

TeleportService:TeleportAsync(7905254789, game.Players:GetPlayers(), --[[TELEPORT OPTIONS]])

You can read up on TeleportAsync here: TeleportService | Roblox Creator Documentation
And TeleportOptions here: TeleportOptions | Roblox Creator Documentation

ipairs() iterator would be more preferable.