Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Does setting a table to nil remove the table?

table["Stuff"] = nil expected > print(table["Stuff"]) > "nil" got > print(table["Stuff"]) > "table:..." (why is the format on this messed up?)

Whats wrong with this method? Do module scripts have any affect on this? I assume this is the wrong way of doing this, so can someone enlighten me?``

2 comments

0

I don't know the position by number.

1 answer

✓ Accepted answer

to accomplish this you have to use table.remove()

http://wiki.roblox.com/index.php?title=Table.remove&redirect=no

Now to answer the question you asked me after, to find the index of a value in a table like you asked, you have to iterate through the table, if you are planning on doing this a lot, I suggest using an index.

local index={}

for i,v in pairs(table) do
	index[v]=i
end

return index["foo"]

3 comments

0

I tried table.remove().. but the table wasn't at all removed. Confirmed that it was the correct # index. Table was still there... thanks for trying to help my stupidity.

0

are you using it correctly? In this instance it would be table.remove(table, 5) if the index of table['Stuff'] was 5

0

If you set the table to nil like this "Data[player.Name] = nil" removes the table.

This discussion is preserved as it was. New answers, comments, and votes are closed.