You can’t get item at index 0 from an array that has no items.
To stop this error from happening, (edit: and to prevent yourself from running code on nothing) do the following any time you are working with an array:
Array → get length of array → if length is more than 0 → do code
Edit: This makes sure you never try to access something from an array that has no members. Now, your actual problem is that the array is empty in the first place and you need to look into whatever code that adds objects to the array.