How to use scenes as saves

Hey, so I want to use scenes in order to have “saves” in my game. Right now I’m stuck on actually duplicating a scene from code (It’s supposed to duplicate a scene. That said scene is supposed to be where the game starts off, so duplicating it makes it possible to make several saves). Here’s my code:

Debug.Log("Creating new game..."); 
// Message that game creation is starting
Scene newGame = SceneManager.CreateScene(savedCharacterName + " - $" + savedBudget + " - " + savedTimeLimit + " days"); 
// Creates a new scene
newGame = SceneManager.GetSceneByName("Main Menu"); 
// Makes the scene that was just created equal to the preset scene
Debug.Log("New game made!"); 
// Confirmation that the scene was made
SceneManager.LoadScene(savedCharacterName + " - $" + savedBudget + " - " + savedTimeLimit + " days", LoadSceneMode.Single); 
// Loads the scene

So yeah, that’s what I got. Gives me this error:

Looks like I need to add the scene to the build settings. Any idea on how to do that? Thanks. Also, the savedBudget and savedTimeLimit variables do not show up as seen in the error, even though they work EXACTLY the same as the variable savedCharacterName. Any ideas for why the name of the scene is messed up too? Super thanks.

Well doing this at runtime is a really odd way to try to save anything with the game states. It’s not made for that. You can only load scenes that are in the build settings, when you create a scene it creates an empty scene and adds it to the current scene. You’d then unload the current scene with UnloadScene and set the new scene active (not sure if you have to set the scene active). Rad more on it here:

But, really this is not a good idea for saving any state of the game. For that you’ll need to learn how to save data to a file and read it back. Unity can save to disk (or registry) with the PlayerPrefs class, but for game states you should learn about serialization, most likely you’d want to read up on JSON serialization.