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)
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