How to keep a variable from changing?

I’m not sure how to word this question so I will use my code to help. What I am trying to do is get a position of an object and while that object is in that position, I want to turn a boolean to true. However, I also want to translate this object so that it moves but if it moves, the boolean will turn to false since it isnt in the correct position. Can anyone help me with this?

Here is the code:

var topRight : boolean = false;

if((transform.position.x == 7.5) && (transform.position.y == 7.5)){

topRight = true;

transform.Translate(0,1,0);

}

What do you mean? Is this not your full code? Just keep topright not set. Sorry if I am missing something.

I seem a bit confused. topRight will only turn to false if you set it to false after it moves from the correct position.

Once you set it to true, it stays true until you set it to false again. So my question is where in your script does it get set to false again?