A Constantly Updating Child Check

Hey guys, I have this code, but I get a frame by frame error of…

UnityException: Transform child out of bounds Toss.Update () (at Assets/Toss.cs:12)

with my current code of…

private void Update()
{
    ***//LINE 12 of Toss.cs |*** if(gameObject.transform.GetChild(0) != null)
    {
        child = transform.GetChild(0);
    }
}

in other words how can I constantly check for a child object, and when ever there is a child, its name to be called through script will be ‘child’… to help with a proper answer, there is only ever 1 child of the parent object, never 2 child objects so only need code relating to a single object, not an array or list of child objects, the child objects contain of different tags and names, so I cannot use tags or names to find the child.

You can check the number of children:

if (transform.childCount > 0)
{
    child = transform.GetChild(0);
}