Is it possible to remove all in a table without remove the table?
✓ ANSWER ACCEPTED
How to all remove in a table?
1 answer
✓ Accepted answer
Yes, it’s possible to remove everything in a table without destroying the table itself (is that even possible?). It just takes a simple for loop and table.remove to accomplish this.
Here is an example :
local cleanthistableplz = {"junk", "more junk", 0572859285, 'Wafflez'}
for i = 0, #cleanthistableplz, 1 do
table.remove(cleanthistableplz, i)
end
So as you can see, I have a table full of strings and stuff. With the for loop, the "i" value goes up based on the number of things in the table and removes them all using table.remove.
Hoped this helped!
I actually don’t know a lot about tables at the moment since I barely use them and wrote this based on this wiki page about tables, so I apologize if something I said was wrong. I also typed all of this on mobile so I can’t even test my script.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
use i=1 instead of i=0, as there is no 0th/0st item in a table
Couldn't you just do
tableToBeCleand = {}thus removing everything in it?Sorry, I said I don’t know lot about tables right now and I thought I had to use table.remove for that. Didn’t know you can just simply do that.