How to load scene name from different script

So I want to load a scene with the scene name that I have saved in a different script, but it always says:

Object Reference not set to an instance of an object

How can I fix this?

public class SaveSlotsMenu : MonoBehaviour
{
    [Header("Menu Navigation")]
    [SerializeField] private MainMenu mainMenu;

    [Header("Menu Buttons")]
    [SerializeField] private Button backButton;

    private SaveSlot[] saveSlots;

    private bool isLoadingGame = false;

    private GameData gameData;

    private void Awake()
    {
        saveSlots = this.GetComponentsInChildren<SaveSlot>();
    }

    public void OnSaveSlotClicked(SaveSlot saveSlot)
    {
        DisableMenuButtons();

        DataPersistenceManager.instance.ChangeSelectedProfileId(saveSlot.GetProfileId());
        
        if(!isLoadingGame)
        {
            DataPersistenceManager.instance.NewGame();
        }

        SceneManager.LoadSceneAsync(gameData.sceneName);
    }

[System.Serializable]
public class GameData
{
  public long lastUpdated;
  public Vector3 playerPosition;
  public int chapterCount;
  public string sceneName;

    public GameData()
    {
        playerPosition = Vector3.zero;
        this.chapterCount = 1;
        this.sceneName = "Start";
    }
}


    public void SaveGame()
    {
    
        if (disableDataPersistence)
        {
            return;
        }

        if(this.gameData == null)
        {
            Debug.LogWarning("No data was found. A New Game needs to be started before data can be saved.");
            return;
        }

        foreach (IDataPersistence dataPersistenceObj in dataPersistenceObjects)
        {
            dataPersistenceObj.SaveData(gameData);
        }

        gameData.sceneName = SceneManager.GetActiveScene().name;

        gameData.lastUpdated = System.DateTime.Now.ToBinary();

        dataHandler.Save(gameData, selectedProfileId);
    }

Hi,

Object Reference not set to an instance of an object

means that you’re trying to access inside the variable memory but the variable has not been instantiated. This error has nothing to do with “accessing a different script” or “loading a new scene”.
In your code, I see that you’re trying to load a new scene using

SceneManager.LoadSceneAsync(gameData.sceneName);

This line of code will never work if gameData is a null variable.
I suggest you to instantiate your variable using the constructor that you wrote before using it :

if (gameData == null) gameData = new GameData();
SceneManager.LoadSceneAsync(gameData.sceneName);

You could initialize the variable somewhere else, but you have to do it before using it.