When you spawn a stone inside the loop then you can't pick it until that event finishes. (You can pick a newly created object by UID only). Those new stones you spawn won't be picked by the 'Pick all' condition.
I'm guessing you have one stone on the layout at the start and you call this function to create more but it's only able to pick that first stone. You'll have to try a different approach.
For example, you could spawn all the stones first, in a different event. Create all stones at (-1000, -1000) with boolean flag placed = false. Then you can have your loop that would be almost the same but instead of spawning stones it moves one of the unplaced stones to the correct position.