Why my teleport script only teleporting 1 player only?

so i made a teleport script refering from roblox documentation but somehow only 1 player can teleport to another place but when another player click the TextButton they aren’t get teleported. so it was like only 1 and only first player able to teleport. Please help me, I want everyone who click the button get teleport and not only 1.

local id = 12977778179

local g = game:GetService("TeleportService")

local button = script.Parent

local player = game:GetService("Players")

local ptt = player:GetPlayers()[1]

button.MouseButton1Click:Connect(function()

g:TeleportAsync(id, {ptt})

button.AutoButtonColor = false

button.Text = ("Please wait a while...")

button.BackgroundColor = BrickColor.Blue()

end)

Because you’re only getting the 1st player from :GetPlayers(). For teleporting a group of players, also consider using TeleportPartyAsync

It doesn’t work. it’s doesn’t teleporting any players or anything now

What did you change from before?

Could do:

for _, Player in pairs(Players:GetPlayers()) do
-- teleport here
end

You using the wrong script and calling the wrong function from teleport service

Place this code in a local script inside the text button

local id = 12977778179

local g = game:GetService("TeleportService")

local button = script.Parent

local player = game.Players.LocalPlayer


button.MouseButton1Click:Connect(function()

	g:Teleport(id, player)

	button.AutoButtonColor = false

	button.Text = ("Please wait a while...")

	button.BackgroundColor = BrickColor.Blue()

end)

You are only getting 1 player from the Players folder.

Consider doing this (if this is a localscript):

button.MouseButton1Click:Connect(function()
player = game.Players.LocalPlayer
g:Teleport(id,player) --tp the person who clicked it
button.AutoButtonColor = false

button.Text = ("Please wait a while...")

button.BackgroundColor = BrickColor.Blue()
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.