Just a quick question to do with how tables work…
Say I had a table:
players = {player1, player2, player3}
Then I use:
table.remove(players, table.find(players, player2))
Would player3 now be players[2] or would it remain in the players[3] slot?
Just a quick question to do with how tables work…
Say I had a table:
players = {player1, player2, player3}
Then I use:
table.remove(players, table.find(players, player2))
Would player3 now be players[2] or would it remain in the players[3] slot?
table.remove shifts the table indices, so yes, the key for the value will change
If you have a table
local players = {
player1, -- index 1
player2, -- index 2
player3 --index 3
}
and remove it with what you said, the table would then be
local players = {
player1, -- index 1
player3 -- index 2
}
meaning the index for player would be 2, so you’d use players[2] to get “player3”