Without knowing rest of the code, structure or what you actually want to implement here.
On top of my head,
1. For each XY element having a sub-event can sometimes cause un-expected loops. I used the word un-expected to explain that they may differ from what we have in our head.
2. To debug this, take it out of this sub-event. Make a new event which gets triggered on click of a button and then press the button at the appropriate time in the game. Keep the debug window open and see the result. If you get correct result, this means a problem while using "Every XY..". If you still don't get correct result with a button, means check your Array values.
/ Umar