There is an action to select a random object A, but before delete it, you should create B or save A’s position: Other way, if you delete A first, then you will not know where to create B
1 - Select random A ===> Create B at A’s position ===> Delete A or
2 - Select random A ===> Save A’s position in two variables ===> Delete A ===> Create B at variable position
Of course (1) is preferred, since you haven’t to create a variable.
It’s almost the same, but instead selecting a random A (this is an action), you need a condition. I can’t help here, since the condition is given by your game. For example if the A you want to replace is the clicked one, the condition is “Button pressed”+“Cursor is over A”, then create B at A’s position, and finally delete A
EDIT: I didn’t note that Darkhog had already answered… is the same explanation, but shorter