Why is my scene not loading?

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

public class LoadAScene : MonoBehaviour
{

	public int SceneToLoad = 0;
	
	public void GoToScene()
	{
		SceneManager.LoadScene(SceneToLoad);
		Debug.Log("Clicked");
	}
}

This script is called by pressing a button, and it works in one scene but not another scene where I need to use it. I copy and pasted the button and it doesn’t work. Please help.

Did you add that scene in Build Settings? If not so, then add it

i think u need an name and no int like this

 public string scenenametoLoad;

 public void GoToScene()
 {
        SceneManager.LoadScene(scenenametoLoad);
 }