ok so first you put
SetLocalVarInt("What is the number" , 1);
this sets the local variable - which is an integer, and has the name of "What is the number" to 1
then, later in the script you can use:
if(GetLocalVarInt("What is the number")==1){ // run code}
you can put SetLocalVarInt("What is the number" , 1); in any function you like, you could even put it in OnStart(). The most suitable place to put the variable would depend on what you want to do.
Example: you have a hallway, halfway down you have a script area, called "Area_1", at one end of the hallway you have another area called "Area_2". If you want something to happen at "Area_1" if, and only if the player has stepped into "Area_2" previously, you could create two AddEntityCollideCallbacks, one for "Area_1" and one for "Area_2". When the player collides with "Area_2", you Set a Local Variable called "Name Here" to 1. in code this is written as:
SetLocalVarInt("Name Here" , 1);
This stores that value as 1. then when you collide with "Area_1", you put
if(GetLocalVarInt("Name Here")==1){ // run spooky code}
therefore when the player first collides with "Area_1", the local variable called("Name Here")==0, this is because by default it is 0. then when the player collides with "Area_2", it is set to 1. then the next time the player colllides with "Area_1", the local variable == 1, so the code executes.