Incomprehensible Error with my loops

so, are you are looking to make a state change when a certain distance criteria is met...

why don't I see any variable called distance?