How to Add Score Across Levels

I have created a game where you shoot different objects that add 50 points and when the final object is shot it adds 200 points. I want to be able to add up the scores so that I can have a high score and a leaderboard when the game ends. The problem I am having currently is that every time the final object is shot and the 200 points are added then next level is opened and the score is reset to 0. I have tried to use the GameInstance class but it is very confusing to me and it hasn’t worked so far. I have uploaded my scoring system that I currently have implemented and that works perfectly.

You’re on the right track using GameInstance and this should work fine except that you are setting the value of TotalScore to be what it already was (Getting and setting the same variable).

You should set it like this, so that it accumulates:

I am not sure if this is what you want, but it will take the TargetScore, add it to the TotalScore, and store it in the game instance. So I am assuming that TargetScore is the total score for that single level.

Also make sure you have set the game use your custom game instance in your project settings.

So now that I have added that to my game and set my custom game instance as the one the game is using how do I make the score that is displayed the one that is being added up by the game instance? (Sorry I’m still pretty new to Unreal)

It works the same but get TotalScore, instead of TargetScore in the HUD.

I tried Replacing the cast to FirstPersonGameMode with a cast to MyGameInstance and got Total Score but then my score didn’t update at all. Is there any other way that I can add the scores up from level to level.