Why is it that when I equip weapons, they rotate in different ways depending on which way I[my character-player] am[is] looking?

Everytime I equip a weapon or the model of my weapon using scripting, I keep running into the same issue. Here’s an example: I have a pickaxe, I can click on it in my inventory and send it to the equipment slot, it goes to the right hand like it’s supposed to, but it never has the proper rotation.
Here is a snip of my code… the code that’s supposed to spawn and give proper rotation to the weapon relative to the direction of my character

for(var x = 0; x < playerInventory.Count; x++){
		GUILayout.BeginHorizontal();
		if(GUILayout.Button(playerInventory[x].icon) && playerInventory[x].itemType == ItemClass.ItemType.Weapon && equipped == false)
		{
			equippedItem = playerInventory[x];
			var weapon : Transform = Instantiate(playerInventory[x].itemPrefab,rightSlot.position,Quaternion.identity);
			weapon.parent = rightSlot;
			playerInventory.RemoveAt(x);
			return;
		
		}

if anyone knows or has experienced my problem and can help, it’d be much appreciated. Thanks.

Hey guys! Through much trial and error I have found the solution and will post it here just in case anyone else has this awful problem!

	for(var x = 0; x < playerInventory.Count; x++){
		GUILayout.BeginHorizontal();
		if(GUILayout.Button(playerInventory[x].icon) && playerInventory[x].itemType == ItemClass.ItemType.Weapon && equipped == false)
		{
			equippedItem = playerInventory[x];
		
			var weapon : GameObject;
			weapon = Resources.Load("WeaponFabs/" + playerInventory[x].name) as GameObject;
			
			print ("WeaponFabs/" + playerInventory[x].name);
			var rightHand : Transform = GameObject.Find("Right_Slot").transform;
			
			var rightSlot : Quaternion = GameObject.Find("Character").transform.localRotation;
			
			var spawn_right_weapon = Instantiate (weapon,rightHand.position,Quaternion.identity);
			
			//spawn_right_weapon.transform.eularAngles = rightHand;
			spawn_right_weapon.transform.localRotation = rightSlot;
			spawn_right_weapon.transform.parent = rightHand;
			
			//var weapon : Transform = Instantiate(playerInventory[x].itemPrefab,rightSlot.position,Quaternion.identity);
			//weapon.transform.parent = rightSlot;
			playerInventory.RemoveAt(x);
			return;
		
		}

don’t mind the notes[the ‘//’ for those who do not know and or are very new], they were there as a result of me testing multiple ways of doing this. So, first off, what is happening here is that by basically clicking the icon for the item in my inventory it get sent to the equip panel by checking if I clicked the icon, (playerInventory[x].icon), then if it’s of the weapon type, and if I already have something ‘equipped’. Next it does the sending of the icon from point A: the inventory to point B: the equip button/section with equippedItem = playerInventory[x];. Next it creates the weapon variable and loads the corresponding weapon from the clicked icon from ‘Assests/Resources/WeaponFabs’ [note it won’t work, the Resources.Load("WeaponFabs/" + playerInventory[x].name) if you do not have a resources folder and if the name of the prefab doesn’t match the name of the weapon/item you assigned the icon to]. Now the most important parts. THIS IS HOW YOU SOLVE THE ROTATING PROBLEM. FIRST: var rightHand : Transform = GameObject.Find("Right_Slot").transform; gets the current position of the Object in the scene named Right_Slot, i.e. this will tell your prefab weapon WHERE to spawn[note: I parented the right-slot,an empty game object, to the bone in the right hand, not doing this for some reason and trying to spawn it on the right hand, resulted in it spawning in not the right area what-so-ever]. var rightSlot : Quaternion = GameObject.Find("Character").transform.localRotation; gets the current ROTATION of the the main character are your bones are attached/parented to and basically allows the weapon to know which way to point. The rest of the code just tells where the variable ‘weapon’ should go and how it should rotate, after attaining said info from the previous lines. Well, that was a mouth full. I really hope this helps someone if they’re looking to fixing their rotating weapon problems! Good luck, guys–and girls!