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

how would I get the playerlist? because it says argument 3 when calling the table.

Asked by 3 years ago
```lua
    elseif Type == "Contract" then
        local Data = game.ServerScriptService.Data_Handler.DataList:FindFirstChild(Player.UserId)

        if Data.CurrentContract.Value == "None" then
            local ChosenPlayer = nil
            local PlayerList = {}

            for _, player in pairs(game.Players:GetPlayers()) do
                if player ~= Player then
                    PlayerList[#PlayerList + 1] = Player
                end
            end

            if #PlayerList > 0 then
                local Contract = PlayerList[math.random(1, #PlayerList)]
                Data.CurrentContract.Value = Contract
                Data.ContractMission.Value = 0
            end
        else
            Data.CurrentContract.Value = "None"
            Data.ContractMission.Value = 0
        end
```

```lua
            if #PlayerList > 0 then
                local Contract = PlayerList[math.random(1, #PlayerList)]
                Data.CurrentContract.Value = Contract --- This is the error
                Data.ContractMission.Value = 0
            end

The error is "argument #3 (string expected, got instance)"
```

Answer this question