Wearing something

Hi… I’m writing a item wearing code. When I click the sword, it becomes Armature’s Right hand’s child, but it’s rotation changes and I can’t set it as I want it to be
code :

void OnMouseDown(){
	if (GameObject.Find("Character").GetComponent<playerScript>().hand==false)//if hand is empty
		transform.parent=GameObject.Find("Character").transform.Find("Armature/Middle Spine/Upper Spine/Arm-R/Elbow-R/Hand-R").transform;
		transform.localPosition=new Vector3(0,0,0);
		transform.rotation= new Quaternion(0,0,0,0);

While I’m not sure why you can’t set the rotation after it’s been parented, a common approach when doing this is to have an empty gameObject already parented to a bone with the desired rotation.

For example, you’d have an object specifically for holding things that you had previously lined up. When you want to equip a sword, or anything else held in a similar manner, you’d parent it to this object, not the hand directly.