Not sure what you meant by that. You dont use any loops in your script. (not onloop)
If you dont want the method to occur again,use area before obstacle ? Therefore if youve passed the obstacle, it cannot click again.
Idk how thats even happening, ur code uses similar principle with myPosition().equals condition. Maybe i just dont see it, kinda hard to read xd
Definetly try to keep the code more organized & compact.