how to press a object to control the animation

Hi, all. I have a question that if in the scene there have a cube,I have made a animation for the cube,if click the cube, it will move the position. Now I wish press it again and it will return to the origion position, so how to do that? thank you very much.

function OnMouseDown () {
animation.Play(“cube_move”);
}

make a second animation of it moving the other way.

look at the cubes position with transform.position.x

if ( transform.position.x < whaterer ) go one way, else, go the other way

EXAMPLE …

function OnMouseDown()
  {
  if ( transform.position.x < 5.0 )
    animation.Play("cube_move");
  else
    animation.Play("cube_move_the_other_way");
  }

NOTE you must actually make a second animation called “cube_move_the_other_way”"

hope it helps !