positions.Length might be were you are getting issues.
Say you have 5 vector3’s loaded into positions… the length is 5 however if you were to try to assign:
transform.position = positions[5];
you would get an error.
An array is a set of variables that the computer stores as one solid block in memory. Each # is an integer for example:
int[] fiveIntegers= new int[5];
These 5 integers look like this in memory:
…[Random stuff]…[int0][int1][int2][int3][int4]…[Random stuff]…
One way to access the individual integers (and afaik the only way in C#) is through indices:
fiveIntegers[0]; // gives you the first element (int0 above)
fiveIntegers[1]; // gives you the second element (int1 above)
...
fiveIntegers[n]; // gives you the (n-1)-th element
An IndexOutOfBoundsException is thrown whenever you access an element that is outside the array. Say you access the 6-th element of an array that only contains 5.
I understand what you are saying, but it’s not the problem. I got that error because all my lines had that Random Spawn Script as component. I don’t know how or why it was there. I removed it at all lines and I don’t get the error anymore. But still, the line goes to the wrong positions. Btw, i checked the positions at transfrom, and pasted the same positions (so where it needs to spawn) at the elements.