Gun Bob Help

Hi everybody ! I have minor problem in my Gun bob script . I have copy the HeadBobber script and modify it . And now its working as GunBob script . But it just moving at Y Axis . When i write this under the transform.localPosition.y

transform.localPosition.x

It just making the gun moving to the center and making annoying move ! I need help for this !

Thanks for the advance .

Use x y and z trial and error it may have something to so with the rotation on your object eg: y may not be up

This is the full script .

 private var timer : float = 0.0;
 public var bobbingSpeed : float = 0.18;
 public var bobbingAmount : float = 0.03;
 public var midpoint : float = 2.0;
 private var waveslice : float;
 private var horizontal : float;
 private var vertical : float;
 private var totalAxes : float;
 private var translateChange : float;

 function Update () {
    waveslice = 0.0;
    horizontal = Input.GetAxis("Horizontal");
    vertical = Input.GetAxis("Vertical");
    if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(vertical) == 0) {
       timer = 0.0;
    }
    else {
       waveslice = Mathf.Sin(timer);
       timer = timer + bobbingSpeed;
       if (timer > Mathf.PI * 2) {
          timer = timer - (Mathf.PI * 2);
       }
    }
    if (waveslice != 0) {
       translateChange = waveslice * bobbingAmount;
       totalAxes = Mathf.Abs(horizontal) + Mathf.Abs(vertical);
       totalAxes = Mathf.Clamp (totalAxes, 1.0, 0.0);
       translateChange = totalAxes + translateChange;
	   transform.localPosition.x = translateChange;
           transform.localPosition.y = translateChange;
    }
 }

But this script just making annoying rotating move and the gun change position to center . I can fix it, but the gun moves like CS 1.6 and i want real gunbob.Anyone can help ?