I'm following the godot saving games article over on the godot docs, and I have a problem with the save system that I don't know how to fix. Basically I'm putting all objects that I want to save in a group, writing a save function for each object that returns a dictionary, finding all objects that are in the group, converting them to JSON and saving them serially in a file. When I load the game I convert each line in the save file to JSON, load the objects by type and add the new object as a child of the parent (defined in the save method).
The problem is that if I add an object to the scene when I already have a save file it will be removed. Is there a way to fix this? The code is basically the one on the docs but with some small modifications that aren't necessary to solve this problem.