So I have this code. It does teleport all the players but it teleports them to different private servers. Is there a way to fix that?
-- server script in ServerScriptService
local TS = game:GetService("TeleportService")
local Part = workspace["Elevator 2p left"].Teleport.Telepart
workspace["Elevator 2p left"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 2p left"].Teleport.Telepart end)
workspace["Elevator 3p left"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 3p left"].Teleport.Telepart end)
workspace["Elevator 4p left"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 4p left"].Teleport.Telepart end)
workspace["Elevator 5p left"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 5p left"].Teleport.Telepart end)
workspace["Elevator 6p left"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 6p left"].Teleport.Telepart end)
workspace["Elevator 1p left"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 1p left"].Teleport.Telepart end)
workspace["Elevator 2p"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 2p"].Teleport.Telepart end)
workspace["Elevator 3p"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 3p"].Teleport.Telepart end)
workspace["Elevator 4p"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 4p"].Teleport.Telepart end)
workspace["Elevator 5p"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 5p"].Teleport.Telepart end)
workspace["Elevator 6p"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 6p"].Teleport.Telepart end)
workspace["Elevator 1p"].Teleport.Telepart.Touched:Connect(function() local Part = workspace["Elevator 1p"].Teleport.Telepart end)
local TPS = game:GetService("TeleportService")
local Players = game:GetService("Players")
-- SAFE TELEPORT MODULE
local SafeTeleport = require(game:GetService("ServerScriptService"):WaitForChild("SafeTeleport"))
local idPlace = 11873076445
-- RESERVED SERVER DATA
local code
local pvSVid
-- DEBOUNCE IF SERVER ALREADY EXIST
local isServerExist = false
-- PLAYERS WHO ALREADY TRIGGERED THE TOUCH
local PlayersActivatedTouchTP = {}
function private(partTouched)
if partTouched.Name == "HumanoidRootPart" then
local isPlayer = Players:GetPlayerFromCharacter(partTouched.Parent)
if isPlayer then
if not table.find(PlayersActivatedTouchTP, isPlayer) then
table.insert(PlayersActivatedTouchTP, isPlayer)
if Players:GetPlayerByUserId(isPlayer.UserId) then
if not isServerExist then
code, pvSVid = TPS:ReserveServer(idPlace)
isServerExist = true
end
if code and pvSVid then
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ReservedServerAccessCode = code
local isTPDone, TPresult = SafeTeleport(idPlace, {isPlayer}, teleportOptions)
if isTPDone then
table.remove(PlayersActivatedTouchTP, table.find(PlayersActivatedTouchTP, isPlayer))
end
warn("TP done?", isTPDone)
warn("PrivateServerId?", TPresult.PrivateServerId)
warn("ReservedServerAccessCode?", TPresult.ReservedServerAccessCode)
end
end
end
end
end
end
workspace["Elevator 2p left"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 3p left"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 4p left"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 5p left"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 6p left"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 1p left"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 2p"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 3p"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 4p"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 5p"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 6p"].Teleport.Telepart.Touched:Connect(private)
workspace["Elevator 1p"].Teleport.Telepart.Touched:Connect(private)