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?

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