How do I make it so that when the screen is first started, the value of the variable is 0, and when the next screen is opened, it receives data received from another screen?

Hello, I hope for your help, let's get right to the problem. I apologize in advance if there is a crooked translation, I am from Russia, I translated with a translator.

I am creating a game on this platform and I need to make sure that when the player opens the second screen (Screen 2), the value of the variable is set to 0 on the first launch. On this screen, the player presses the button to go further, when the variable value is 0, the button is blocked. As soon as the player presses the button, under the condition that the value is 0, the button is blocked and the variable is assigned to 1. Then the player moves to another screen, where he performs various tasks and eventually returns to the same screen. As he completes all the tasks on the other screen, upon return, the value of the variable is 4 and the player can press the button and go to the next level. That's basically all the logic.

The main problem is that when the player moves to this screen, the variable is not initialized as 0, but initialized as a void. That is, it does not matter at all. Accordingly, there is no first stage, the player simply cannot press the button so that it locks and he goes to perform tasks on another screen.

Please help me, I will try to answer all your questions.

Use tinydb.

On the "other screen", set the "data" to a tag in tinydb.

On the screen where the variable is 0, call the tag data back from tinydb and set it to the variable.

To stop this happening on start up, later, place a check to always initially set the variable to 0.

I haven't used TinyDB yet. Maybe there is another way? I only need one thing, so that when a person opens Screen 2 for the first time, the value of the variable is 0, and on the next openings it will be the same or different, depending on the player's actions. Okay, if this can only be done with TinyDB, please could you sketch out an example code of what it might look like? On YouTube, all the videos are about how to save data on one screen, and I have a player moving between screens. If it's not hard for you, send us a sample code, I will be very grateful.

See this example of changing button images, but keeping them changed when switching screens. That should give you the idea