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)