Cursor Lock (but only for in-game scenes)

Hi guys, so I want the cursor to be locked to the center of the screen where the crosshair is. If the player gets killed it will take them to a replay/exit scene, the problem is that when they’re taken to this scene (which the script isn’t in, so it should no longer be active) the cursor is still locked, this means that the player can’t make the choice weather to Replay or Exit and they’re stuck, any suggestions?

Cursor Lock Code:

// lock at beggining
function Start ()
{
Screen.lockCursor = true;
}
//unlock in mid game

function Update()
{
Screen.showCursor = false;

if (Input.GetKeyDown(KeyCode.P))
if (Screen.lockCursor)
Screen.lockCursor = false;

else{
Screen.lockCursor = true;
}
}

You could try putting Screen.lockCursor = false; in the start method of the scene you have switched to. Or unlock the cursor before switching scenes.