✓ Accepted answer
table.remove removes something at a particular point. It does not remove a thing in the list.
You have to find where player is inside WinnerTable to be able to table.remove it.
for i = 1, #WinnerTable do
if WinnerTable[i] == player then
table.remove(WinnerTable, player)
end
end
Remark: The above only works if you are sure something is in the list only once. (In this case you should be good as long as you don't have any bugs elsehwhere!) If it's something's in it multiple times, potentially they won't all be deleted [Ex.: Why?]. All that's needed to fix that is to go backwards: for i = #list, 1, -1 do.
Alternative?
There is another way to do this, though (if you want to -- I'm not arguing one way is better than the other).
Right now, you know that player is still alive because they are in the WinnerTable. You could define it differently; for instance, they could have a Winner BoolValue in their player. When they start the game, the value is set to true. When they die, the value is set to false.
You no longer have a WinnerTable, then. Instead, if you need a list of players, you just look for those that are Winners. (See here for implementation details)
2 comments
That's what I did for my mini game, game.
Thanks BlueTaslem! You've been really helpful for getting my coding along.