It is because you’re trying to fill the index [1] of your array with nothing, To fix it you could branch your for loop at the end of your sequence instead of after the “AddItem” function, like that you would be sure that all the code who fill the array will be executed before you iterate on it.