Clear all children component of a component

i would like to clear all children of a component.
I have this :

But for a reason i do not understand it leave one child alive, then when i redo the same function it destroy the last one.

The problem is caused by the fact that those actors that got destroyed initially, once they are destroyed they are removed also from the array automatically because they didn’t exist anymore by the engine "probably is a precaution system to prevent to have arrays with actors that doesn’t exist.
So, probably time you get to the last child to remove the first was already moved in the garbage and removed from the array automatically, meaning that last item got moved to the 1st index and in the last you have nothing. To solve the problem you need instead of the normal for loop to use a reverse for each loop in order to destroy actors from the last index in the array to the first, this should avoid that the array lose elements while you trying to remove them

1 Like

MK_Studio is correct however i’d recommend just caching the ChildrenArray into a local variable so the pure node isnt constantly called