How do I destroy a specific clone of a GameObject?

I am trying to instantiate prefabs and then be able to walk around with a first person controller and destroy the ones I deem unworthy.

public GameObject RabbitObj;

void Start()
for (int i=0;i<=RabbitInit;i++)
		{
			Position.x=(float)(UnityEngine.Random.value-0.5)*90f+50f;
			Position.y=100.5f;
			Position.z=(float)(UnityEngine.Random.value-0.5)*90f+50f;
			var qq=GameObject.Instantiate(RabbitObj,Position,Quaternion.identity);
			qq.name=("Rabbit"+i.ToString());
			RabbitObject.Add(qq);
		}

I have been using the Destroy function but it does not have the desired outcome. It deletes one object but when I try delete another object it returns the following error:

“MissingReferenceException: The object of type ‘GameObject’ has been destroyed but you are still trying to access it.”

I think I understand why it is saying that (as it has deleted the “RabbitObj” GameObject); I just dont know how to delete just one of the cloned game objects I have instantiated.

I would really appreciate any help :slight_smile:

Firstly I suggest you make RabbitObject an array list, even better, a list using generics.

public List<GameObject> RabbitObj;

You will need to add:

Using System.Collections.Generics; 

to the top of your script.

When you want to destroy item X from the list you can call Destroy(RabbitObj); and then remove the item from the list.