Object reference not set to an instance of an object (805591)

public class MotorCarretera : MonoBehaviour
{
    public GameObject motorCarretera;
    public GameObject[] contenedorCalles;
    public float speed;
    public int selectorDeCalle;
    public int contadorDeCalle = 0;
   
    // Start is called before the first frame update
    void Start()
    {
        juegoTerminado = false;
        creaCalle();
    }

    // Update is called once per frame
    void Update()
    {
        motorCarretera.transform.Translate(Vector3.down * speed * Time.deltaTime);
    }

    public void creaCalle()
    {
        selectorDeCalle = Random.Range(0, 5);
        GameObject Calle = (GameObject)Instantiate(contenedorCalles[selectorDeCalle],new Vector3(0,50,0),transform.rotation);
        Calle.SetActive(true);
        contadorDeCalle++;
        Calle.name = "calle" + contadorDeCalle;
        Calle.transform.parent = motorCarretera.transform;
        GameObject piezaAux = GameObject.Find("calle" + (contadorDeCalle - 1));
        Calle.transform.position = new Vector3(transform.position.x,
                                                piezaAux.GetComponent<Renderer>().bounds.size.y +
                                                piezaAux.transform.position.y,
                                                piezaAux.transform.position.z);

    }

}

The error happen when i try to use Calle.transform.position, i don’t know where is the error, i already instantiate it, it’s still working but i am learning, so i want to know where is the error, thanks for your help

The error code should say the line number. If you post the entire error someone will likely help you.

Most likely your GameObject.Find call is not finding anything. GameObject.Find is an error-prone and slow way of getting object references. I suggest using a different method.

Anyway if you want to just solve your specific issue, use Debug.Log and print out what string you’re trying to find, then compare that to the obejct names in your scene.