+2 votes

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

in Engine by (31 points)
edited by

1 Answer

0 votes
Best answer

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

by (31 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.