Having a problem with a variable used as a flag

Perhaps more concerning the robots movement systems would help with a more useful response?