# Toggle MouseLook On/Off Problem

**URL:** <https://discussions.unity.com/t/toggle-mouselook-on-off-problem/73237>\
**Category:** Questions & Answers\
**Created:** [June 12, 2013, 7:04pm UTC](https://discussions.unity.com/t/toggle-mouselook-on-off-problem/73237 "2013-06-12T19:04:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holmklo](https://avatars.discourse-cdn.com/v4/letter/h/8c91f0/32.png) [@Holmklo](https://discussions.unity.com/u/Holmklo)\
**Post date:** [June 12, 2013, 7:04pm UTC](https://discussions.unity.com/t/toggle-mouselook-on-off-problem/73237/1 "2013-06-12T19:04:59Z")

</div>

I have a problem with the MouseLook script. When i press Esc the pause menu comes up but i cant disable the FPS-MouseLook. I have the JS version of MouseLook. I set the script on Main Camera and FPS Controller. But it says:

.

NullReferenceException: Object reference not set to an instance of an object  
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)  
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)  
Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)  
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)  
MouseDisable.Update () (at Assets/Scripts/MouseDisable.js:6)

.

.

This is the script i wrote, please help?

```
function Update () 
{ 

	if(Input.GetKeyDown("escape"))
	{
		GetComponent("MouseLook").enabled = !GetComponent("MouseLook").enabled;
	}
	
}

```

---

<div class="post-metadata">

**Author:** ![DaveA](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DaveA](https://discussions.unity.com/u/DaveA)\
**Post date:** [June 12, 2013, 7:13pm UTC](https://discussions.unity.com/t/toggle-mouselook-on-off-problem/73237/2 "2013-06-12T19:13:06Z")

</div>

Make sure this script is on the exact same object as MouseLook. Otherwise, you may want to GameObject.Find and/or use GetComponentInChildren
