Parent gameObject in script

Hi,

How can I change the parent of a game object in javascript?

I’ve a weapon that is parented to the spine, but if I press the “z” key, I want the weapon is parented to the right hand.

  • Weapon is linked to Spine > Press “z” key > Weapon is linked to Right_Hand

Please help me.

Greets

transform.parent =

http://docs.unity3d.com/ScriptReference/Transform-parent.html