Why are my AI's moving to 0,0,0 sometimes

So i’ve set up a little scene with some AI characters. When it begins every actor with the name “BP_Collect” and “BP_Deposit” get put into an array. Then when my character wants to move, i use a function to get a random value from the array, and another function to move them to that location.

Now i know this works, half of the AI travel to where they are supposed to be, however the other half do not, they travel to 0,0,0. I thought it might be something to do with timing. so i added a delay but got nowhere with that. Theirs no pattern on which AI does it, sometimes its none of them, sometimes the majority. Their is nothing else getting put into the array to mark it as 0.0,0 either.

Yep it was exactly that. I did think of it finding a value that wasnt there, but when it didnt show something extra when i used “Print String” i ruled it out. Thank you!

Instead of length try using last index. If length of array is 1 and you try to get a random value from 0 to 1 then the array index of 1 would be invalid. See if that solves the issue.