I dont think that the variable is the problem. Instance variables are perfect for this kind of stuff.
You probaly have a problem with picking the right instances of objects. And maybe with the logic.
You should post a capx to get good help.
First: read this https://www.scirra.com/manual/75/how-events-work
And this wil set you in the right direction: