Local variables get reset every tick. Quote from the manual:
------
1. Local variables reset their value to the initial value every tick. This is by design, and intended to match how local variables work in real programming languages.
------
If you need to store the variable more than 1 tick, it's got to be global.
One trick I'm using (because I don't like to have a lot of global variables either) is this:
1. Create a sprite on the layout where you need the "local" variable and give it some "meaningful" name. For example I need some local variables that would store their value across ticks on my "Play" layout, I create a sprite called "varsPlay" and add it to the Play layout, somewhere out of view (-100, -100 coordinates or something)
2. On this sprite, add all the local variables you need, as Instance variables. Like in your example, you'd add a "number" variable to the sprite varsPlay, and in your event you'd have varsPlay -> Add 1 to instance variable "number", and Text -> set text to varsPlay.number.
I hope this helps you keep your design tidy, it does help me do that. One more advantage you get if you do this is that you can use "boolean" variables too, which you can't if you use proper variables.
Cheers!