Stop aiming when starting to run

hi,

i have used the AimDownSights script, found on the Unify-wiki
(http://www.unifycommunity.com/wiki/index.php?title=AimDownSights)

i am now trying to edit it in a way the player can not aim when running, or will stop with aiming when the player starts to run.
i have made it so the player can not start aiming when he is allready running, but when the player starts to run when holding the right mouse button (aiming) he does not stop aiming.

here is the script how i made it so far:

var gun : Transform; 
var nextPos = 0.0; 
var nextField = 40.0; 
var nextPos2 = -0.2; 
var dampVelocity = 0.4; 
var dampVelocity2 = 0.4; 
var dampVelocity3 = 0.4; 

function Update () { 

  if (Input.GetButton("Run")) {
       //adjust viewpoint and gun position
       nextField = 60.0;
       nextPos = 0.5;
       nextPos2 = -0.4;
       
       //speed up turning and movement speed 
       GetComponent(FPSWalkerEnchanted).walkSpeed = 6;
       GetComponent("MouseLook").sensitivityX = 6;
       camera.main.GetComponent("MouseLook").sensitivityX = 6;
       camera.main.GetComponent("MouseLook").sensitivityY = 6;
	   return;
	   
	   } else {



   var newPos = Mathf.SmoothDamp(gun.transform.localPosition.x, nextPos, dampVelocity, .3);
   var newField = Mathf.SmoothDamp(Camera.main.fieldOfView, nextField, dampVelocity2, .3);
   var newPos2 = Mathf.SmoothDamp(gun.transform.localPosition.y, nextPos2, dampVelocity3, .3);
   
   gun.transform.localPosition.x = newPos;
   gun.transform.localPosition.y = newPos2;
   Camera.main.fieldOfView = newField;
   

   
   if (Input.GetButton("Fire2")) {
       //adjust viewpoint and gun position
       nextField = 40.0;
       nextPos = 0.0;
       nextPos2 = -0.2;
       
       //slow down turning and movement speed
       GetComponent(FPSWalkerEnchanted).walkSpeed = 1.5;
       GetComponent("MouseLook").sensitivityX = 2;
       camera.main.GetComponent("MouseLook").sensitivityX = 2;
       camera.main.GetComponent("MouseLook").sensitivityY = 2;
   } else {
       //adjust viewpoint and gun position
       nextField = 60.0;
       nextPos = 0.5;
       nextPos2 = -0.4;
       
       //speed up turning and movement speed
       GetComponent(FPSWalkerEnchanted).walkSpeed = 6;
       GetComponent("MouseLook").sensitivityX = 6;
       camera.main.GetComponent("MouseLook").sensitivityX = 6;
       camera.main.GetComponent("MouseLook").sensitivityY = 6;
	   }
	   
	  
   }
}

i am new to scripting with Unity, so i hope you can post what i did wrong, so i can learn from it.

btw: i did not get any error messeges when testing it in-game.

if (Input.GetButton(“Run”))
{
//Stop Aiming here
}

thanks for the reply, but i think that is what i am doing here:

function Update () { 

  if (Input.GetButton("Run")) { 
       //adjust viewpoint and gun position 
       nextField = 60.0; 
       nextPos = 0.5; 
       nextPos2 = -0.4; 
        
       //speed up turning and movement speed 
       GetComponent(FPSWalkerEnchanted).walkSpeed = 6; 
       GetComponent("MouseLook").sensitivityX = 6; 
       camera.main.GetComponent("MouseLook").sensitivityX = 6; 
       camera.main.GetComponent("MouseLook").sensitivityY = 6; 
      return; 
       
      } else {

it sets the gun’s position back to the original position (not aiming) and if the button is down it stops processing the script further with the ‘return;’ if i am right, or is this a wrong way of making the aiming stop?
it does not work with this script, probably something simple since i am just practising with .JS one week now…