Hi. I’m trying to insert a specific group of players to a table and teleport them to a private server. Everything’s fine until it tries to teleport them, because it says “TeleportToPrivateServer must be passed an array of players.”. I don’t know what I’m doing wrong, I don’t think the table is empty because when I tell it to print the first element and touch the part, it does print my name.
local function onTouch(partTouched)
local humanoid = partTouched.Parent:FindFirstChild("Humanoid")
if humanoid then
local character = Players:GetPlayerFromCharacter(partTouched.parent)
if not table.find(playersTouching, character) then
table.insert(playersTouching, character)
print("Inserted to table")
partTouched.Parent.HumanoidRootPart.CFrame = tphere.CFrame
end
end
end
game.Workspace.partthing.Touched:Connect(onTouch)
Here’s the teleport part of the script.
while wait(20) do
if #playersTouching >= 1 then
print(playersTouching[1])
wait(1)
print(playersTouching[2])
local TS = game:GetService("TeleportService")
local code = TS:ReserveServer(5484604783)
print("Server created")
TS:TeleportToPrivateServer(5484604783, code, playersTouching)
end
end