GunScript error

this is my GunScript

when i have it disabled, my game works fine, when i enable it, the gun is stuck at my body (as it suppost to)
but i cant move at all and look around!
this works if i disable the GunScript
when i move the camera it forces it back to the default location
and my scene view screen is moving wheird when im not even doing anything
i dont think this suppost to happend…

it messes my entire game up!
here is the code:

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

var rotateSpeed : float = 0.3;
var holdHeight : float = -0.5;
var holdSide : float = 0.5;
var racioHipHold : float = 1;
var hipToAimSpeed : float = 0.1;
@HideInInspector
var racioHipHoldV : float;

function Update () 
{
	if(Input.GetButton("Fire2"))
	{
		racioHipHold = Mathf.SmoothDamp(racioHipHold, 0, racioHipHoldV, hipToAimSpeed);
	}
	if(Input.GetButton("Fire2") == false)
	{
		racioHipHold = Mathf.SmoothDamp(racioHipHold, 1, racioHipHoldV, hipToAimSpeed);
	}
	
	transform.position = cameraObject.transform.position + (Quaternion.Euler(0, targetYRotation, 0) * Vector3(holdSide * racioHipHold, holdHeight * racioHipHold, 0));
	
	targetXRotation = Mathf.SmoothDamp(targetXRotation, cameraObject.GetComponent(MouseLookScript).xRotation, targetXRotationV, rotateSpeed);
	targetYRotation = Mathf.SmoothDamp(targetYRotation, cameraObject.GetComponent(MouseLookScript).yRotation, targetYRotationV, rotateSpeed);
	
	transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
}

it is using the LookScript:

var defaultCameraAngle : float = 60;
@HideInInspector
var currentTargetCameraAngle : float = 60;
@HideInInspector
var racioZoom : float = 1;
@HideInInspector
var racioZoomV : float;

var racioZoomSpeed : float = 0.2;

var lookSensitivity : float = 5;
@HideInInspector
var yRotation : float;
@HideInInspector
var xRotation : float;
@HideInInspector
var currentYRotation : float;
@HideInInspector
var currentXRotation : float;
@HideInInspector
var yRotationV : float;
@HideInInspector
var xRotationV : float;
var lookSmoothDamp : float = 0.1;
 
function Update () 
{
    yRotation += Input.GetAxis("Mouse X") * lookSensitivity;
    xRotation -= Input.GetAxis("Mouse Y") * lookSensitivity;
    
    xRotation = Mathf.Clamp(xRotation, -90, 90);
    
    currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, xRotationV, lookSmoothDamp);
    currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp);

    transform.rotation = Quaternion.Euler(currentXRotation, currentYRotation, 0);
}

Let he forum know what errors you are getting, and what lines they are on. Also I helps to describe what is going on in the game as well. After all it only takes one type o to create havoc lol.

changed it :wink: