How would I go about making an animation affected by this script?

So I made an animation called “M1911Idle” and it is attached to the the arm holding it. It works, but when I use another script to “add weight” to the gun, like when you turn, the gun moves a bit, not just sit in one place. But, with the “M1911Idle” animation running, it doesn’t work. How could I go about making this script work while the animation is playing?

Script:
public var MoveAmount : float = 1;

	public var MoveSpeed : float = 2;
	
	public var GUN: GameObject;
	
	public var MoveOnX : float;
	
	public var MoveOnY : float;
	  
	public var DefaultPos : Vector3;
	
	public var NewGunPos : Vector3;
	
function Start(){

	DefaultPos = transform.localPosition;

}
	
	
function Update () {

	MoveOnX = Input.GetAxis( "Mouse X" ) *Time.deltaTime * MoveAmount;
	
	MoveOnY = Input.GetAxis( "Mouse Y" ) *Time.deltaTime * MoveAmount;
	
	NewGunPos = new Vector3 ( DefaultPos.x+ MoveOnX, DefaultPos.y+ MoveOnY, DefaultPos.z);
	
	GUN.transform.localPosition = Vector3.Lerp(GUN.transform.localPosition, NewGunPos , MoveSpeed * Time.deltaTime);

}

Thanks.

Simple: create an empty game object, and put your animated object as a child to it. Now just attach your script to the newly created parent object.