# Highscore saving even when lower

**URL:** <https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398>\
**Category:** Community & Industry Discussion\
**Tags:** math, unreal-engine, score, question\
**Created:** [July 24, 2015, 2:52pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398 "2015-07-24T14:52:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikachu\_92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mikachu\_92](https://forums.unrealengine.com/u/Mikachu_92)\
**Post date:** [July 24, 2015, 2:52pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/1 "2015-07-24T14:52:38Z")

</div>

[http://puu.sh/jbbfC/3207d46731.jpg](http://puu.sh/jbbfC/3207d46731.jpg)

The above blueprint is in the playerBP and fires once the actor dies. It “works” in that it saves the current score as highscore and the highscore is loaded on the next run.

It does not work however as even when current score is lower than high score it saves current score as high score.

I don’t see what is wrong here as it should be checking that the current score is higher?

Please help!

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 24, 2015, 6:10pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/2 "2015-07-24T18:10:29Z")

</div>

You fires that “script” every the actor dies? Because every the system will create a new SaveGameObject, so when you cast to saveHighScore i think it will be always the default value.

---

<div class="post-metadata">

**Author:** ![Mikachu\_92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mikachu\_92](https://forums.unrealengine.com/u/Mikachu_92)\
**Post date:** [July 24, 2015, 6:28pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/3 "2015-07-24T18:28:17Z")

</div>

Yes - when you die and end the level it triggers.

So it would be better/right to create a savegame at the start of the game opening (if no savegame exists) then simply cast to savehighscore each death?

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 25, 2015, 11:50am UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/4 "2015-07-25T11:50:56Z")

</div>

Yes, you should create only one savegame at the begin of the game and then, every the player dies, using the cast, you check if the score is greater than the score saved.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_776011b61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_776011b61](https://forums.unrealengine.com/u/anonymous_user_776011b61)\
**Post date:** [July 25, 2015, 1:40pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/5 "2015-07-25T13:40:43Z")

</div>

But I am with TAM. Why would the branch not stop it being written?

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 25, 2015, 1:47pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/6 "2015-07-25T13:47:00Z")

</div>

Because if you create a new save game everytimes the “high score” value will be set to default value, and every the new score will be higher than 0, so he will write that value.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_776011b61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_776011b61](https://forums.unrealengine.com/u/anonymous_user_776011b61)\
**Post date:** [July 25, 2015, 1:50pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/7 "2015-07-25T13:50:48Z")

</div>

Even with the branch? Good to know.

So if you make a Savefile the first the games plays, you never make one again or do you create one every the game loads?

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 25, 2015, 1:53pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/8 "2015-07-25T13:53:41Z")

</div>

You should just create one savegame file at the begin and then, when the game start, you control if the savegame already exists. You save the value of the savegame into a var, then during your game you use that var for a cast, and modify every value into the savegame, and when you want to save those changes you have to use the node called “savegame to slot”.

I can create an example if you need

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_776011b61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_776011b61](https://forums.unrealengine.com/u/anonymous_user_776011b61)\
**Post date:** [July 25, 2015, 1:57pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/9 "2015-07-25T13:57:36Z")

</div>

So when you load a second, third etc, would you use a Is Valid to make sure you do not over right by mistake?

Sorry, have not done Save Game yet, and chugging Tam’s post.

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 25, 2015, 2:04pm UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/10 "2015-07-25T14:04:38Z")

</div>

When you load your savegame through the “Load savegame from slot” you should set the var “savegame” with the value that this node return, and then yes, you can check if is valid, but should be if the savefile exist.

And when you have to modify a value you just pin out that var and use a cast

---

<div class="post-metadata">

**Author:** ![Zedimasterali](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zedimasterali](https://forums.unrealengine.com/u/Zedimasterali)\
**Post date:** [July 15, 2021, 4:32am UTC](https://forums.unrealengine.com/t/highscore-saving-even-when-lower/326398/11 "2021-07-15T04:32:01Z")

</div>

please do
