=true then =false then back to true

this is in my pause menu to lock the cursor to the center but when i press escape free it for a bit to press option buttons then when i press escape again to lock it to the center again,what arent i doing?

var SwitchOnSound:AudioClip;
var SwitchOffSound:AudioClip;
private var Off : boolean = false;
private var On : boolean = true;

function Start () {
    Screen.lockCursor = true;
}

function Update()
{
    if(Screen.lockCursor)
    {
       if(Off)
       {
         if(Input.GetKeyDown(KeyCode.Escape))
         {
          On = true;
          Off = false;
          AudioSource.PlayClipAtPoint(SwitchOnSound, transform.position);
         }
       }
       else
       {
         if(On)
         {
          if(Input.GetKeyDown(KeyCode.Escape))
          {
              On = false;
              Off = true;
              AudioSource.PlayClipAtPoint(SwitchOffSound, transform.position);
          }
         }
       }
    }
}

Seems to me you aren’t toggling your Screen.lockCursor at any point, it always == true;

I don’t know what your entire project entails and what you use On and Off for, but seems to me you could really simplify this.

if(Input.GetKeyDown(Keycode.Escape)){
  Screen.lockCursor = !Screen.lockCursor
  if(Screen.lockCursor)
    AudioSource.PlayClipAtPoint(SwitchOffSound, transform.position);
  else
    AudioSource.PlayClipAtPoint(SwitchOnSound, transform.position);
}