I made part of an aiming down your sight script, how doo i move the gun, help!

I tried to move the gun using lerp, slerp and transform.position, none worked, help!!!

here’s my script:

using UnityEngine;
using System.Collections;
 
public class AimingDownSight : MonoBehaviour {
    private Vector3 newPosition;
    void awake()
    {
       newPosition = transform.position; 
    }
    void Update () 
    {
       positionChanging();
    }
 
    void positionChanging()
    {
       Vector3 positionA = new Vector3 (0.3946627, -0.1788931, 0.7112392);
       Vector3 positionB = new Vector3(0.009421766, -0.1324487, 0.5510964);
 
 
       if (Input.GetMouseButtonDown(1))
       {
         newPosition = positionB;
 
       }
 
       else
       {
         newPosition = positionA;
       }
    }
}

You may still need to attach the script to your gun in the editor.

But even if that works you need to fix the positions you have listed. They are absolute positions, in world space. You will want positions relative to the player’s location, otherwise your gun will stay stuck in the center of the map.

A simple way to do this is to make empty gameobjects at each of those coordinates then drag them onto the player object, so they will move around with him. Then, make public references to their transforms in your script and move the gun’s position from one transform to the other instead of positionA to positionB.

You want to structure your player like this:
Cam >
GameObject(animations and such) >
Gun

Then you want to move your gun transform locally to the GameObject, so 0,0,0 is at the center of the gameobject and you move it from there.