Top Score Variable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MDordio
:warning: Old Version Published before Godot 3 was released.

I am making a game that generates diferrent scores every time its played, and i want to make a variable that holds the top score, the problem is i cant find away to store the last score without overwritting it with the new score generated everytime i open the scene again.

For example if a game is played in the end i will have a variable like score = 10
and i want to compare that “10” with score of the next game and if it´s superior i will update my “top score” variable with the new score

Currently my function is this:

var top_correct_s = 0

func top_score_s():
if(top_correct_s < Globals.get("ANSWERS_CORRECT_S")):
	top_correct_s = Globals.get("ANSWERS_CORRECT_S")
	R_top_S.set_text(str(top_correct_s)+str("/10"))
else:
	R_top_S.set_text(str(top_correct_s)+str("/10"))
pass

thanks in advance

:bust_in_silhouette: Reply From: MDordio

I manage to solve my problem by using a globals variable as an array

I will just leave this here in case it´s usefull for anyone