How to change position.Z , by clicking another game object ?

Hi .
So here is my question :

we have 2 game objects .
cube[A] and an emptyObject**.**
B has become an animation (by using sprite renderer,sprite editor and sprite mode : multiple ) that has position ( x , y , z ).
coz sprite renderer makes it a sprite any way.
pix :frowning: I used a gif image for making an example )
1)
[33687-untitled-1.jpg|33687]**
***********************
2)
that is what I call B (franeshtain is the empty object ). with position :
[33688-untitled-2.jpg|33688]**
3)
[last][3]
I want to do this :
when A is clicked , B’s position.z changes . to what I wrote in the script .
like :
function OnMouseDown(){ //mousedown on A

GameObject.transform.position.Set(0,1,-1);

}
but it doesn’t work :stuck_out_tongue:
can u help me by the script ? js only plz .
THX : D
EDIT :
I wrote this: ( check the comments please)

public var B : GameObject ;

function OnMouseDown(){
B.Transform.position.Set(0,3,-1);
}

every thing was fine.
but when I run it , and click on A (the cube ) , I got an error .
and get out from the run section :frowning: why?
error :
[link text][4]
**
**
[3]: http://www.shiaupload.ir/images/70902976827619897759.jpg
[4]: http://www.shiaupload.ir/images/94166758880194963098.jpg

The error message says that your Object B isn’t set to anything. You have to drag&drop the GameObject from your hierarchy into the property of the script inside the Inspector.