You should try to avoid using booleans, try to check
Also NEVER EVER try to use while loops in scripts.(Except when using some Timer to prevent while loops geting stuck)
While loops are doomed to mess your script, instead use for loops or make better use of the onLoop method.
You can always add me on skype and i'll take a look at your script on how to solve your issue.
Skype is in my sigg