unable to change position of instantiated object - get nullreference exception

I have spent many hours on this and not sure why its not working!

public class Brick : MonoBehavior
{
public Transform Brick4;
public GameObject myobject;

void OnMouseDown()
{
myobject = Instantiate(Brick4, transform.position, transform.rotation) as GameObject;
myobject.transform.Translate(1, 1, 1); // This is where the error occurs
}
}

My guess is you haven’t set Brick4 in the inspector. So it’s going to be null in your script, and Instantiate will return null as well.

it was set in the inspector… i just figured it out

I had to use this
Transform IC = Instantiate (Brick4, transform.position, transform.rotation) as Transform;
IC.Translate (1,1,1);

this is what was able to make it work