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

attempt to call a table value error?

Asked by 4 years ago

I am trying to get this part of my script to get all the players and randomize their teams, and spawn them into the game but I keep getting an error that says "attempt to call a table value" on line 6, I don't know why this is happening and couldn't find anything online about it, could someone please help?

while wait() do
    -------------- INSERT INTERMISSION MESSAGE HERE
    wait(10)
    --ROUND LOOP STARTS
    local playerlist = Spectators:GetPlayers()
    local player = playerlist(1, #playerlist)

    if player then
        if numberKiller == 0 then
            player.TeamColor = BrickColor.new("Really red")
                numberKiller = 1
                    numberSpectators = numberSpectators - 1
            print(""..numberKiller.."")
            print(""..numberSpectators.."")
        else if player then
                player.TeamColor = BrickColor.new("Cyan")
                    numberSurvivors = numberSurvivors + 1
                        numberSpectators = numberSpectators - 1
                print(""..numberSurvivors.."")
                print(""..numberSpectators.."")
            end
        end
    end

    wait(3)
    for _, c in pairs(game.Players:GetChildren()) do
        local humanoid = c.Character:WaitForChild('Humanoid')
        humanoid.Health = 0
    end

end

(I cut off a large portion of the script as it is 100+ lines of code which I'm sure no one wants to read through)

0
is there a reason why you did print(""..numberSurvivors.."") when you couldve just done print(numberSurvivors)? zadobyte 692 — 4y
0
lol raid6n 2196 — 4y
0
change line 6 to local player = playerlist[math.random(1, #playerlist)] raid6n 2196 — 4y
0
I Would vote your comment but I don't have 25 reputation yet ConceptBasics 2 — 4y

Answer this question