Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I get error, "TeleportToPrivateServer must be passed an array of players". Can anyone help me?

Asked by 2 years ago
Edited 2 years ago

I have used this script with a button clicker for a while and now I'm transitioning it over to a ScreenGui. I get this error though.

local clicker = script.Parent
local numOfPlayers = 0
local requiredPlayers = 1
local playerQueue = {}
local ts = game:GetService("TeleportService")

local function hasPlayer(tab, ply)
    for i, v in pairs(tab) do
        if v == ply then
            return true
        end
    end
    return false
end

local function joinQueue(player)
    if not hasPlayer(playerQueue, player) then
        print("player has joined the queue")
        numOfPlayers += 1
        playerQueue[numOfPlayers] = player
    end
end

local function queueLoop()
    while wait(1) do
        if numOfPlayers >= requiredPlayers then
            print("prepare to teleport")
            local code = ts:ReserveServer(9125662769)
            ts:TeleportToPrivateServer(9125662769, code, playerQueue)
            numOfPlayers = 0
            playerQueue = {}
        end
    end
end

spawn(queueLoop)
clicker.MouseButton1Click:Connect(joinQueue)

These are the errors I get from the script: Photo

Answer this question