I have a table, like this:
alive = {}
Then in my round script it sets a BoolValue, named InGame, inside every player, to true, then adds them to the table.
Then I want the round to end, so I have a for do loop:
for time = 1,100 do wait(1) for i,v in pairs(game.Players:GetPlayers()) do if v.InGame.Value == false then table.remove(alive, v.Name) end if #alive <=1 then break elseif #alive == 0 then break end end end
But after I kill someone (I have a separate script that sets InGame to false when one dies), I get this error:
23:22:50.463 - Workspace.Rounds:115: bad argument #2 to 'remove' (number expected, got string)
The line it's referring to is the 5th line in my second script (the one that ends the round)
Please help?
for time = 1,100 do wait(1) for i,v in pairs(game.Players:GetPlayers()) do if v.InGame.Value == false then table.remove(alive, i) end if #alive <=1 then break elseif #alive == 0 then break end end end
the table.remove(x,y) function takes two parameters. X being the table you want to remove something from, and Y being the INDEX (Location) of the object you want to remove from the table.