how to unhide cursor when going to main menu?

Hi I am working on a level and when that level objective is complete , I want the game to restart back to the main menu. the problem is that I have a cursor lock on my character which I need , so when complete that objective of the level I get taken to the main menu , but my cursor is locked still . I want know how can make it unlock when I go to the main menu .

here is the cursor lock script
………………………….

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class MouseLock : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(“1”))
{
Cursor.lockState = CursorLockMode.Locked;

        Cursor.visible = false;
    }

    if (Input.GetKeyDown("2"))
    {
        Cursor.lockState = CursorLockMode.None;

        Cursor.visible = true;
    }
}

}

……………………………………………………………………………………….
here is my player collecting script which takes me to the main menu

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class PlayerScriptversiontwo : MonoBehaviour {

private int coinAmount;
public Text CountText;
public Text WinText;
public int totalCoin;
private void Start()
{
    UpdateUI();
    WinText.enabled = false;
}
private void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("Books"))
    {
        coinAmount = coinAmount + 1;
        other.gameObject.SetActive(false);
        UpdateUI();
    }
}
void UpdateUI()
{
    CountText.text = "Collect Books: " + coinAmount.ToString();
    if (coinAmount >= totalCoin)
    {
        WinText.enabled = true;
        SceneManager.LoadScene("TitleScene");
        
    }

}

}

why i dont see my post in help room

Did you write the code yourself? You already have the code you need in there. But I’m a little confused as it seems you lock and unlock the mouse by pressing 1 or 2. Is that correct?

Add these to lines immediately before your load scene line:

Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;