table.Remove not working

So I have a table. And for that table Table.Remove is not working.

Now I have a pretty good idea why.
How I remove the items I do this:

			for n, item in pairs(keysDownTable) do
				table.remove(keysDownTable,n)
			end

Now How I add items to the table is like this

keysDownTable['W'] = Enum.KeyCode.W

My guess it has something to do with how I add it to the table. Now I need to get the number placement of the item so I can remove the item.
I do this in the for loop.
Isnt N suppose to be equal to the number of the item in the table? Basically its position in the table?

I have no idea so thats why Im here!

table.remove only works when the second parameter is a number (no error if nil), if you give it any value other than number or nil the error will be:

invalid argument #2 to 'remove' (number expected, got "string/table/Vector3" etc)

To remove a value from a dictionary (a table that does not use numbers as an index) you should

keysDownTable[Key] = nil
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.