HOw do i chnage the position of an object?

I have two empty game objects attached to my character, one on the hip and one on the hand and I have a gun which is attached to the empty game object on the leg and I want to change the position of the gun and set it to the empty game object which is attached to the hand so when I press the K key the guns appears in the hand. How can i do this?

I have tried this

var gun : Transform;

function update ()
{
            var gun = Instantiate (gun, transform.Find("SpawnPoint2").transform.position, Quaternion.identity);
}

This script is just instantiating the gun at spawn point 2 and the gun just stays there, I want the 1 gun which is already in the scene to change its position and show up at spawn point 2 and attach it to the hand. Thanks

Create another empty gameobject. put it in hand.
When you press “k” set guns position and rotation to the empty gameobject in hand.

a little confused

First, you have a gun in the scene… however you are instantiating one?

I assume that you want to do something like this:

gun.transform.position=gameObject.Find("SpawnPoint2").transform.position;
gun.transform.rotation=gameObject.Find("SpawnPoint2").transform.rotation;
gun.transform.parent=hand.transform;

Thanks for the reply and script, its working fine =)

However the second line of your script

gun.transform.rotation=gameObject.Find("SpawnPoint2").transform.rotation;

was giving me errors, saying something about Quaternion so I took that line out and it works fine.

function gunsdrawn ()
{
if (GunsDrawn == GunsDrawn)
gameObject.Find("gun1").transform.position = gameObject.Find("SpawnPoint2").transform.position;
gameObject.Find("gun1").transform.parent = gameObject.Find("SpawnPoint2").transform;
if (GunsDrawn == !GunsDrawn)
gameObject.Find("gun1").transform.position = gameObject.Find("SpawnPoint").transform.position;
gameObject.Find("gun1").transform.parent = gameObject.Find("SpawnPoint").transform;	

print (GunsDrawn);
}

u can also use Vector3Lerp it will easy