Is it possible to get a cloned gameObject's parent name?

Hey guys, right now, I can’t seem to get my cloned object’s parent’s name.

After instantiating my object, it became a child of another object.

So, this code

if (transform.parent.name == "DropZone1")
    pos = new Vector3(-0.475f, 0,0);

returns a NullReference. I’m guessing it’s trying to reference its prefab, which doesn’t have a parent. But it’s already in the game, so it should be trying to reference it’s current parent instead.

    print (transform.parent.name);
    Debug.Log (transform.parent.name);

both also returns a NullReference.

Anyone knows a solution to this?
Thanks!

I am assuming the code that’s giving you a NullReference is attached to the instantiated object. So, when are you executing that code?

Maybe you are executing it in Awake which is being executed before AddChild has parented the new object to the desired parent?