Learn the SceneManager API. To switch scenes in code, you need to add this at the top of your script:
using UnityEngine.SceneManagement;
Then use one of these methods:
// Load by scene NAME (recommended):
SceneManager.LoadScene("MainMenu");
SceneManager.LoadScene("Level1");
SceneManager.LoadScene("GameOver");
// Load by scene INDEX:
SceneManager.LoadScene(0); // MainMenu
SceneManager.LoadScene(1); // Level1
SceneManager.LoadScene(2); // GameOver
Name vs Index: Using names is more readable but must match exactly (case-sensitive!). Using index numbers is shorter but breaks if you reorder scenes. Choose whichever you prefer.