Pong Game, My highscore and score does not get imported to the second screen

I tried to implement a highscore and score into a tinyDB such it gets imported to the second screen, however, the score and highscore values do not return properly (shows 0 for both)

First picture shows blocks for screen1, and second picture shows blocks for screen2 (directs to screen 2 after game ends)

See those little :x: marks on your blocks ? You can not initialize a global variable to call data. Initialize to an empty string and set them to call data on Screen initialize

Is this what you mean?

It seems to work now, however, my highscore is being reset. Everytime I get to screen 2.

You don't really need global variables, if you work directly from TinyDB:



Notice that I do not try to open Screen1 from Screen2.
You have to close screens as often as you open them, to avoid filling memory.
Also notice that you have to refresh the screen from TinyDB on your return.

1 Like