How to destroy all the items with one function?

How do I destroy all the items with a tag?

I have looked at things but I am not exactly sure what I am doing wrong or what I have to do.

They are “cubes” coming at you. and I want the game to restart and delete all the cubes comming at you. The cubes are tagged as badCubes

I tried using:

var badCubesarray = GameObject.FindGameObjectsWithTag (“badCubes”);
for (var badCubes in badCubesarray)
Destroy(“badCubes” in badCubesarray);


var badCubesvar = GameObject.FindGameObjectsWithTag (“badCubes”);
for (var badCubes in badCubesvar)
Destroy(“badCubes” in allBadCubes);

I understand the logic is to create an array variable, add all the objects of that tag to it, and then create a for all the objects with that tag to destroy. But what exactly do I have to write?

Destroy("badCubes" in badCubesarray);” isn’t correct syntax. It’s just “Destroy(badCubes);”.

(Since you seem to be new here: Please format code using the code button, don’t post comments as answers, and remember to accept/vote up answers that help you. Thanks!)

after a little bit of headake, I made it work! that and I finished the game on time for an assignment

var array : GameObject[] = GameObject.FindGameObjectsWithTag("taggedCubes");
var item : GameObject;
	for (item in array)

My game for you fellas to check on, the cubes disapear when the game is restarted.