Javascript Gun Look Script Problems

I have been trying to implement a basic gun and i have got all the functionality enabled except the gun moving up and down. It rotates up and down but does not move with the camera. Here is a video of the problem:
Unity gun problem

Here is the gun code:

#pragma strict

var cameraObject : GameObject;
@HideInInspector
var targetXRotation : float;
@HideInInspector
var targetYRotation : float;
@HideInInspector
var targetXRotationV : float;
@HideInInspector
var targetYRotationV : float;

var rotateSpeed : float = 0.1;

var gunPosHeight : float = -0.1;
var gunPosSide : float = 0.65;
var gunPosZ : float = 1.12;

function Update () {
	transform.position = cameraObject.transform.position + (Quaternion.Euler(0, targetYRotation, 0) * Vector3(gunPosSide, gunPosHeight, gunPosZ));
	
	targetXRotation = Mathf.SmoothDamp(targetXRotation, cameraObject.GetComponent(mouseLook).xRotation, targetXRotationV, rotateSpeed);
	targetYRotation = Mathf.SmoothDamp(targetYRotation, cameraObject.GetComponent(mouseLook).yRotation, targetYRotationV, rotateSpeed);
	
	transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
}

you could return a Vector3 point directly in front of the cameras direction with:
theposition = transform.TransformPoint(Vector3.forward * 100);

then use this to calculate target rotation:
gunface=Quaternion.LookRotation(theposition-transform.position);

then slowly rotate your gun towards your new variable gunface:
transform.rotation = Quaternion.Lerp(transform.rotation, gunface, Time.deltaTime * 10);

I never done this before. I would think theses funtions would be all ya need though!