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

How do I remove objects from a table?

In this script I'm working on; if you click a button it'll insert content from another table into an empty table, and if you click another button it should delete the content from the previously empty table. But an error message would appear saying, "Players.KatsuneSniper.PlayerGui.StartGui.main:207: bad argument #2 to 'remove' (number expected, got Object)"

for i = 1, #currentcam do
	table.remove(currentcam, currentcam[1])
end

4 comments

0

You have to give it the table number position.

0

Thanks

0

Np.

1 answer

table.remove() uses two arguements, an array, and the key you want to remove, not the value. In order to remove the value, try this:

for i = 1, #currentcam do
    currentcam[1] = nil
end

table.remove()

1 comment

1

STOP STEALING MY ANZERZ!

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