move a gameobject to a position when a button is pressed, and when its not pressed move it back?

I want to move an object to a position when a button is pressed, and when its not pressed move it back, how woul i do this, i’ve tried transform.position but that didn’t work, help!?

First, make sure you event when a button is pressed or released is called. You can use Debug or add breakPoint to see if theyre call. Then you can simply use

this.transform.position = Vector3.one;

to change the position of the gameobject.