Very strange behavior with Get/Array

I have this simple function that compare actors in an array and returns the desired one.

There’s a simple array of actors. Get the one at ‘index’ (index starts with 0) and set it to ‘temp’, then increment index, get item at new ‘index’, compare the two, if ok set new one to ‘temp’, if not do nothing, then increment ‘index’ and continue.
Ends when array’s length == index (index would be out of bounds, so it means that there are no more actors to try).

There’s a very strange behavior when executing this. I have it binded to W,A,S,D, and each binding produce a different and precise error always related to the highlighted branch (get_item13 failed, get_item6 failed, etc…). I have quadruple-checked thousands of times now, and can’t really figure out what the problem is…


Solved with a forloop, but I still can’t figure out what is wrong with that logic…

One issue with that setup is you’re incrementing the index after testing that it is within bounds, when it really should be the other way around. The way it was set up in that shot, when you get to index 9 in a 10-item array (which would be the last index), it passes that test. But then you’re incrementing it after that to index 10 and trying to use it, which gets you out of bounds.

Not sure why its giving you item13 failed though.

Yes, you are right on that. Between other things, further experimentation included moving that test forward. I even tried incrementing index manually (in case there was a problem with the increment node) but nothing, always item13 error…
I rewrote it all with a forloop and the problem is not present.