desabling MouseLook script

Hello, :smile:
I’m new to Unity and to scripting.(I don’t know much about JavaScript).

I try to desable the “MouseLook” from the main camera in order to get a still screen while displaying an interactive text.

My code ia as follow:

cameraObj = GameObject(“MainCamera”);
aScript = cameraObj.GetComponent(MouseLook);
aScript.enabled = false;

I obtain a NullReferenceException.

It would be kind if somebody could explain to me the
“Why” of this message and give me the right coding.

Many thanks.

That error means that it’s not finding the MainCamera in the first line, or Try something like this:

var ml: MouseLook = Camera.main.GetComponent(MouseLook);
if(ml) {
ml.enabled = false;
}

That ‘if’ in there should keep it from spitting up errors in case it can’t find either the MouseLook script or camera.

psx[/code]

Thanks psx.