Destroy child from parent in array (Child instatiate)

HI, how i can destroy a child that was instatiate, from a parent in a array ?

this is a error:


the error is: NullReferenceException: Object reference not set to an instance of an object

and by this nothing happend:


or is is better to disable it ?

This should work if there is an object parented to ‘actualParent’, which is named ‘actualChild(Clone)’ (make sure the name doesn’t have a space before the opening parenthesis). If not, it at least doesn’t throw an exception.

GameObject go = actualParent.transform.FindChild("actualChild(Clone)");
if(go != null) Destroy(go.gameObject);

If possible, I would rather store a reference to the object when it is created, to avoid searching through the hierarchy and comparing strings is usually not the most robust way of identifying objects.