Why is the player not getting removed from the table?

Hello,

I was working with this code of mine, whenever I tested it, the player would be added to the table, but not removed. This table is changed when a player joins or leaves the game.

(All in a local script).

Joins:

Removed for leaking.

Leaves:

Removed for leaking.

Variables:

Removed for leaking.

Thank you,

– dmk

1 Like

Question: Shouldn’t this be handled in a Server Script instead?

Also, you might wanna add some print statements to debug that RemovePlayer function to see what gets activated/changed

I tried to do it in a Server script, however, I ran into a couple of issues. It may have just been user error.

Whenever I printed the table when the player joins and leaves, the player would be in the table. When the player left, it seems that they are still in the table since it still prints their name. When they rejoin, they are still in the table.

Feedback about what I should try to do would be very appreciated.

Mind my last reply, I did try this out as my own test and it did the same

a={}

table.insert(a,2,"name1")

table.insert(a,8,"name2")

for _,v in pairs(a) do

print(v)

end

print(a)

wait(2)

table.remove(a,8)

wait(1)

print(a)

and it did exactly the same thing, maybe its a bug, I will look into it with the Lua handbook

I suggest you find a way to avoid using the player’s id as the index