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

How to fix must be passed by an array of players?

Asked by 2 years ago

Hi, I made a part where if you touch it it would teleport everyone in the server to a new place. I used Players:GetPlayers() as an easy way to achieve this however I have encounter this error:

TeleportService:TeleportToPrivateService must be passed by an array of players.

Here is my code:

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local AllPlayers = Players:GetPlayers()
local Power = script.Parent.Power.Value
local debounce = true

script.Parent.Touched:Connect(function(hit)
    if debounce == true then
        debounce = false
        if hit.Parent:FindFirstChild("Humanoid") ~= nil then
            --if Power == true then
                    wait(0.5)
                    local Reserve = TeleportService:ReserveServer(8532865349)
                    print("Teleporting Players")
                    TeleportService:TeleportToPrivateServer(8532865349,Reserve,AllPlayers)
                    print("Teleported Players")
                    print(AllPlayers.Name)
                wait(1)
                debounce = true
            --end
        end
    end
end)

How can I refer to all the players in the server in a different way?

Answer this question