GetAxis main thread issues

So I’m working on half of a mouselook script. But I keep running into the error “GetAxis can only be executed in the main thread”

I’ve tried everything I can, stuff I’ve tried has a number next to it for reference.

#pragma strict
var mouseX = Input.GetAxis("Mouse X"); 1
var mouseX = Input.GetAxis("Mouse X") * Time.deltaTime; 2

function Start () {
	var mouseX = Input.GetAxis("Mouse X"); 3
	Screen.lockCursor = true;
}

function Update () {
	var mouseXcompile = mouseX * Time.deltaTime; 4
	transform.Rotate(mouseXcompile, 0, 0);
}

4 obviously isn’t there when 2 is. If I do 3, I get tons of errors.

why don’t you just simply use this script ?

I’ve just joined this forum so thought i would have a go at answering this.
I would use smoothdamp to slowly follow the mouse position, you can add Time.deltaTime to this.
This is what i would do, script is attached to the camera, hope it helps!

    var look_sensitivity : float = 1.0;
    var curr_x_rotation : float;
    var curr_y_rotation : float;
    var look_SmoothDamp : float = 0.1;
    var y_rotation : float;
    var x_rotation : float;

    //get desired rotation from mouse
	y_rotation += Input.GetAxis("Mouse X") * look_sensitivity * Time.deltaTime;
	x_rotation -= Input.GetAxis("Mouse Y") * look_sensitivity * Time.deltaTime;
	
	//limit the x rotation (so you can't spin)
	x_rotation = Mathf.Clamp( x_rotation, -90, 90);
	
	//smooth the transition to desired rotation
	curr_x_rotation = Mathf.SmoothDamp( curr_x_rotation, x_rotation, x_rotationV, look_SmoothDamp);
	curr_y_rotation = Mathf.SmoothDamp( curr_y_rotation, y_rotation, y_rotationV, look_SmoothDamp);
	
	//apply rotation to camera
	transform.rotation = Quaternion.Euler( curr_x_rotation, curr_y_rotation, 0);