Kick existing object out of box

I am making my first game. it is top down format.

I made a worm that carries letters and places them in boxes to spell words. It uses the sticker feature to pick up the letter and when the worm comes in contact with the box, the letter unsticks and moves to the center of the box. The problem is, it will let the worm put multiple letters in the same box.

I can code it to kick out a specific letter if any other letter is in the box but I can’t figure out how to make it kick out the existing letter and replace it with the new one.

Can you share screen snips of the existing code so we can see what you’ve done already? The someone can better advise on how to add your requested functionality.

This is how the worm drops the letter in the box:

Condition: “Worm” is in colision with “letter_box”
sub condition: “a” is in colision with “worm”
action: Unstick “a” (from “worm”)
Action line 2: Change position of the center of “a”:a set to letter_box center x() (x axis) letter_box center y() (y axis)

This grouping repeats replacing a with each letter of the alphabet.

The following will only allow a to be kicked out of the box and not any other letter reguardless of which letter was in the box first so this code is pretty much useless:

If all of these conditions are true:
“a” is in collision with (letter box)
if one of these conditions are true:
letter_box is in collision with b
letter_box is in collision with c
letter_box is in collisoin with d
(you get the idea this continues for every letter)
move “a” to random positions, where each stop is at least 300px and at most 600px from the current position. move toward angle 360 with a bias of 0.

Yes, I understand that the “and” and “or” conditions are useless here. Being brand new, I thought it might make a difference in the expression. I had hoped that the code would be executed more like the following:

If “a” comes in contact with “letter_box” when there is already a letter in the box then move “a” to random position…

which is actually the opposite of what I wanted to do. I wanted to move the other letter but if I did so, and reversed it to say if “a” comes in contact with “letter_box” then move “b”,“c”,“d” etc… all of the letters would move even the ones that are not in the box. and even if they’ve been placed in another box.

I also tried to write something where there is a condition and action for each pair of letters, I deleted that code already but there are several issues with it. It went something like this:

If both of these are true:
“a” is in collision with letter_box"
“b” is in collisoin with “letter_box”
move “a” to a random positon.

In this case this section would be repeated with every combination of letters.
It doesn’t matter which letter the player is trying to put in the box. The “a” would always be the one that is kicked out of the box.

What I think I need to do is someting like this:

If any two sprites are placed in the same x,y position then move one to random positon (preferably the one that was there first)

if any two letters are in collision with “letter_box” then move the first to a random position.

I hope this is clear.