AI Finding Bugs

How the heck do I make this behave?
Correcting a stupid logic error!