Questions about arrays

Hi All,
I have a script that instantiates a new GameObject (a sphere) of the same type when the right arrow is pressed. If I wanted to destroy these objects in the reverse order that they are created (say, with the mouse button), I need to do the following:

  1. create an array that will count the number of objects that are cloned.

  2. rename each clone as it is created with something like “GameObject+1”.

  3. store the number in the array

  4. code something that destroys the most recent clone created.

I’m having trouble with the array creation/add thing. I’ve read through the docs on arrays, but didn’t know how to make a counter of sorts. I have a feeling it has to do something with “++” but don’t know for certain. (again i’m more of a designer struggling to learn how to code).

So. here’s my code so far:

var arr = new Array
var ObjectToBe : Rigidbody;

function Update () {
	
	if (Input.GetButtonDown("Vertical")) {
// Create a new object (clone) of the sphere
	var clone : Rigidbody;
	clone = Instantiate(ObjectToBe, transform.position, transform.rotation);
	print ("added another ball");
	
	if (Input.GetButton ("Fire1"))
Destroy (gameObject);
	}
	}

as always, thanks!

d

Why not use an ArrayList of gameObjects and insert at the beginning?