Okay so say I put all the game players into a table. And then I mathmatically choose a single player from that table. If I want to remove that player from the table how would I do it? It seems you can't just table.remove an object.
✓ ANSWER ACCEPTED
Is there a way to remove objects from a table?
1 answer
✓ Accepted answer
table.remove removes something at a particular index. You have to know where the object is in the table to be able to remove it.
local players = game.Players:GetPlayers()
local player = -- some player, decided somehow
for i = 1, #players do
if players[i] == player then
table.remove(players, i)
end
end
1 comment
0
Okay thanks!
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Please be more concrete. What are you trying to do? What is the number that you're trying to assign? And why?
Okay so you can't remove an object from a table. Is there a way to do that?
That is basically what I am trying to ask.
For key, value tables simply set the value to nil e.g. [table key] = nil