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

How do you remove all variables in a Table?

I was using table.insert() to add in players but I want it to clear using table.remove(), but I think table.remove only removes one chosen variable, I want it to remove all. Any help please?

1 comment

0

local table = {stuff = "1"} table = {}

1 answer

✓ Accepted answer

Well, there are many ways of doing it, but here are two.

Way 1: The pointlessly excessive way

function clearTable(tab)
	for i,v in pairs(tab) do
		table.remove(tab,i)
	end
end

Way 2: The nice and elegant way

Table = {}

Way 2 just overrides the old table with a new fresh blank one.

1 comment

0

Thanks

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