Help WIth Tables!

Hey Everyone My Name Is Nehoray

I Started Working On NEW Moderation Tool To Help Keep The Game Safe!

Table Name: Mods
How Can I Remove Player From Table And table.remove(Mods, player) is Not Working For Me Its Return nil And How Can I Save The Table After I Remove The Player
Any Ideas Why And How Remove The Player?
Thanks To Everyone Who Help!

1 Like

Attempting to use table.remove requires an index(a number), not string value.

If your table is a dictionary: Mods[player] = nil
If your table is an array:

for i, moderator in next, Mods do
    if moderator == player then
        table.remove(Mods, i)
        break 
    end
end
4 Likes

Hey,
Any Ideas How To Save The Table?

2 Likes

You should look into data stores. When you have all of that set up you can simply use UpdateAsync to save the table.

1 Like

Why use next on an array instead of ipairs (or even just table.find)?

3 Likes

I have a bad habit of using next() every time. ipairs() would be recommended(or your other suggestion, the newer functions from the global table).