Error message when using loop index as an array index to get value in arrays My program moves an ultrasonic sensor around 260 degrees and the values are recorded down in an array variable every 2 degrees it turns. It moves back and measure it 3 more times, storing each measurement in a different array variable (in total there are 4 array variables). 

I want to get the average value from the four array variable thus I use the 'read at index' mode of the array operations.


It uses the loop index to get the index of the arrays. Then it takes the values and calculates the average before putting them in another variable array. However, the brick shows an error message right after the ultrasonic sensor is finished measuring.

I removed some parts of the program in order to find the cause of the error and I found that it might have something to do with the loop index. It might also have been because the array is not found. I tried using another variable that adds one every loop and then uses it to get the index but the message would appear.

I am not sure why there is the error, nothing contradicts the program, there is no math error, it should have worked. I hope you guys can tell me why this happens and how to solve it. Thank you!

Here is the complete program:

Clarifications
 It loops 130 times as the ultrasonic sensor measures every 2 degrees it turns, so if it turns 260 degrees, there will be 130 measurements, 130 values in the arrays.
After testing and researching for a while, I found out that the first  lines of code that controls the moving of the ultrasonic sensor is the cause of the error. Previously, the code will make the motor move 2 degrees, then get the measurement of the ultrasonic sensor and put it inside the numerical array. It then loops 130 times so there is 130 measurements and 260 degrees of rotation.

What I am doing is to replace the entire array with that one value. Thus, when I get the value of the array, I am getting an non-existent value. Also, the array starts from zero, not one, so using the loop index for the array will not work as the loop index will not display a zero value index.  

Instead, I should use the 'write at index' mode of array operations. This way, it will add values to the array, not replace the entire array with that one value.

Now this is correct. Before that, I thought that the loop index was the cause of error.  

First time answering my own question, Im so proud lol.