disable script when i press escape??

hey, i have this java script that locks the mouse for my FPS

function Update () {
Screen.showCursor = false;
Screen.lockCursor = true;
Screen.lockCursor = false;
}

if(Input.GetKeyDown("escape")
  {
   paused  = !paused ;
 
    if(paused) //Do Stuff When Paused
     {
     Screen.showCursor = true; 
        }
         else // Do stuff when unpaused
           {
              Screen.showCursor = false; 
               }
 
               }
                 }

it shows error saying, Assets/_Scripts/MouseLOCK.js(10,3): BCE0044: expecting ), found ‘{’.

i need it so when i press escape it turns off the lock script so that way i can navagate the menu and when i press escape again it turns lock back on.

thanks guys

you use no boolean… (R6)

if(input.GetKeyDown("escape")) {
//you say paused = !paused
paused = true; //if you tap escape, than is pause true
if(paused) {
//do some stuff...
}
//you don't need an else, but you can do it if you like to
}

Maybe this works better…

succes

i changed it to

function Update () {
Screen.showCursor = false;
Screen.lockCursor = true;
Screen.lockCursor = false;
}

if(Input.GetKeyDown("escape")
  {
   paused  = !paused ;
 
    if(paused) //Do Stuff When Paused
     {
     Screen.showCursor = true; 
        }
         else // Do stuff when unpaused
           {
              Screen.showCursor = false; 
               }
 
               }
                 }

but it gave me error saying, Assets/_Scripts/MouseLOCK.js(10,3): BCE0044: expecting ), found ‘{’.

can anyone re write it for me?? i thought i fixed it but nope :frowning:

thanks