Array loses it's elements

So, I was making a shop in which you could put multiple items and sell them one by one. I achieved that by making an array variable, adding object references into it and then removing the first object in array and the same object in game when the player activates the shop.
This works fine with single objects, but breaks when I put multiple objects into it, by “forgetting” each second object put inside, no matter the object amount. It still sells the object if i remove the other ones first though.

Here is the code:

Top screenshot is the code for adding/removing objects in the array, bottom is for removing the object when selling the item.


(Sorry for sticking screenshots together, can’t put more than one media file in here)

Am I doing something wrong? “Make Array” doesn’t seem work.

You’re removing 0 index each time
1678019107689

1 Like

Oh, so Destroy Actor removes the reference from the array?

Nope, the destroyed actor ref is still in the array, but this ref will be invalid because there is no such actor. So, you need to remove it from the array. I’d do this before the DestroyActor node

There are two ways to remove from an array