I want to stop DontDestroyOnLoad (gameObject); when I go back to my main menu so that my player doesn’t load on the main menu. I tried
if (Application.loadedLevelName == "MainMenu") {
} else {
DontDestroyOnLoad (gameObject);
}
But I then looked at it and realized that it would only work if I went back to the Main Menu on the Main Menu.