How do i detect what part the motor has to use to aim?

I have created a motor that follows the mouse, but there is one issue.


The motor needs to use the part that is stuck to the chassis for everything to work, but how do i detect what piece is the chassis and what piece is the arm?
The motor can be flipped upside down and mess everything up.

On the picture the motor should use the bottom part to make the arm rotate to the mouse position.
Every block is unanchored.

So you can try this;

Set the part that is supposed to be the motor to glue(a surface property)