I'm having trouble with Game Instances

I’m a complete beginner to Unreal so bear with me here.

I’m trying to create a “speedrun timer” by following this tutorial on YouTube: How To Create A Game Timer in Unreal Engine 5 - YouTube

However, the timer resets to 0 every time a new level is loaded. So, I understand that game instances allow you to store variables globally.

I’m trying to somehow put the logic from the YT tutorial’s player blueprint into my game instance blueprint, but nothing seems to be working.

How do I do this? If you need any more information, please let me know. I’m completely new to Unreal so I don’t really know what you may need to help.

Thanks so much!!

Hey @KytoYouTube !
I think you’re gonna want to take a look at save states. You’ll want to basically create a float in the save state that will store the timer value between levels. There are a bunch of videos on how to create them and they’re pretty simple once you realize what’s going on and I can help explain them if you have any confusion afterwards.

But the best way to think about them is to imagine they are like a journal that writes down data for the computer to read and get information from. Let’s say the player starts out with 5 lives and they die and they have four lives now. When the player saves the game, there is a separate file (the save state) in which you can store data, whether it be integers, strings, floats, bools, etc. and the program can read from it. So you would store an integer called lives and when the player saves, it will save their amount of lives which is now 4. If they were to exit the game and then come back, at the start-up, you can set their amount of lives to be whatever it says in the save state.

Likewise, you can do this with the timer. You create a variable in your save state called “timer” of type float and each time the level is about to be unloaded, you save your current time to the save state and when you open the new level, you set the current time to whatever that saved time is.