Clearing a table

Hey guys

Simple question I hope.

I have a table keeping track of asteroids that are spawned. When the game is over and I press the try again button, I reset the score to 0 and go back to the start menu… but when I press play again, the asteroids are all still spawned and the game ends instantly. I need to figure out how to empty the table but not completely delete the table when I press the try again button.

Any tips would be greatly appreciated, thanks!

@Crumble - for a table named T, either of these should clear everything

T = {}
for i,t in pairs(T) do T[i]=nil end

@Ignatz - Awesome, that worked perfectly! Thanks so much!

What do i and t stand for in that line of code?

i is the index, and t is whatever is stored in the table at that index.

so if earlier you had done something like T["example"] = 15 then i could be “example” and t would be 15