Level made to saving isn't working

welp nvm im unable to fix this now i undone everything i just did to troubleshoot now I’m running into this error
TravelFailure: ClientTravelFailure, Reason for Failure: ‘Invalid URL: /Game/ThirdPersonBP/Maps/MainMenu_level’. Shutting down PIE.

ok this is what i have but im geting the error TravelFailure: ClientTravelFailure, Reason for Failure: ‘Invalid URL: /Game/ThirdPersonBP/Maps/MainMenu_level’. Shutting down PIE.

i have no idea whats going wrong

Huh?! why is saving so hard I was understanding until I got to “You need a function that takes data from “load game from slot” and “sets” current game instance variables prior to using them.” then I just had a massive brain fart because I need game instance variables? the only variable im using from the game instance is the slot name and the default value is what i want to have for the slot. im setting the level from get current level name am i not supposed to do that? Thats why i only have the slot name variable in game instance.

the error occures after making it to level 2 then quitting the game and then pressing play the second time.

Sorry forgot about this post. So let’s look at the logic here. Screen shot 2 is actually the first thing to fire off. You click “play” a game instance is initialized with default values for everything (i.e. “savegameslotname” is DEFAULT) the main menu widget opens up, you click the start button which goes to the game instance and calls the function “saving main menu”. This function checks if there is a save game by looking at the variable “savegameslotname” which as I mentioned before would be a default value so the answer should be FALSE leading to the creation of a save game object and the player starting at level 1. So you play through reach the end and hit screen shot 3 which show the overlap event that triggers the opening of level 2 AND calls the function “goal reached” in the game instance. This function then “loads” a game with the identifier stored in the variable “savegameslotname” which would be the DEFAULT value and then proceeds to SET the level variable in the save game object and then saves the game out to the slot identified by the variable “savegameslotname”. Now if you exit the game and hit play again, you start this process over. At no point do you “load game from slot” and then immediately SET variables in the game instance. This is the only way to actually have the game “remember” where you previously were. You need a function that takes data from “load game from slot” and “sets” current game instance variables prior to using them.

Also, when exactly does this error occur? The first time you hit play? After you reach the end of level one? The second time you hit play after exiting? I need more details about what you are doing to cause the error. But as per my above comment, this entire saving system needs work. Here is an example of what I mean from my game.

To be honest, I am kind of lost in your code myself. I will try and simplify, looking at my last post I realized you probably don’t need all of that because you don’t have any other variable to save except the level “number”. Regardless, here is the basic logical flow of how save game objects work. You hit play, you create a “game instance” this remembers everything that happens until you quit. Then it gets reset to default. If you want to “save” something this is where the save game object comes in handy because it actually stores data from your play period on your hard drive. BUT in order for that to be useful you need to “get it” from the hard drive and then “set” your current game variables using that data. You don’t use save game variables during game play unless you are doing something weird. Think of it like a temporary container for information that won’t be destroyed when you quit. So now that we got that covered, what you want to do is play the game, then beat a few levels and your game instance should know what level you are currently on (or I suppose you COULD do this in the level BP) when it comes time to quit you want whatever entity “knows” the current level to then tell the save game object to “remember” that value. And you do this by having a variable in the save game object that can hold that data type so in this case a “name type” variable corresponding to the level you just beat. You “create” a save game object, “set” this variable within in, then “save” it to a slot. Now you can quit and the data is stored on the hard drive. When you hit play again you can’t just expect the game to know what it “saved”. So you tell it to “load game from slot”. It pulls the data off the hard drive, then you must “get” the variable with the level name out of the save game object and tell it to use that to “open” a level. This will open the last level you played. When you are finished you once again need to save the level name to the same slot as before.

Also try hooking up your target of the “level” pin to the saversubclass variable not directly to the cast node in the first screen shot. Dunno if that matters but might be an issue if the cast node isn’t pulling anything at that point you try and access the variable. Another thing to try, change your “level” variable to a “name type” instead of a string, might be an issue converting a string to a name. And one last thing I just thought of, since your levels are named “1,2,3” you might have an issue since in C++ variables can’t start with a number. So you might have some type of issue with the conversion to name type like that. Try renaming your level to L1, L2, L3 etc and see if that fixes it.

i knew this by “why is saving so hard” i meant why is this not working even though it seems like im doing everything correctly

ill try all of these and come back to you

reason#1 cant connect level to saver subclass says its not compatible
reason#2 but the get current level name makes a string so i would have to convert it anyways
reason#3 umm i tried renaming them i got an error i forgot to copy it then it just deleted my level without my consent D; WTH

ok i remade the level i lost and renaming the levels did not work and neither did the other recommendations

fixed it the problem seemed to come from converting the string variable from the get current level name node to a name so i fixed it by changing the variable of the save game from a string to a name and getting rid of the get current level name all together now when reaching the goal for the level before i run the function for goal reached i will set a name variable for the level reached manually that is in the game instance then use that variable to set the save game variable

I fixed it! the problem seemed to come from converting the string variable from the get current level name node to a name variable so i fixed it by changing the variable of the save game from a string to a name and getting rid of the get current level name node all together now when reaching the goal for the level before I run the function for goal reached I will set a name variable for the level reached manually that is in the game instance then use that variable to set the save game variable

I’m glad you figured it out cuz I was fresh out of new ideas ha

:D…