Placement System on multiple objects?

Title says it all really. I was wondering how would I extend a placement system in a way that it is able to move up onto multiple surfaces as seen in this gyazo:
https://gyazo.com/c7ef7d8e7a98be9b1782f4d8442e9bd0

I have managed to make a system where it is constrained in a border and moves fine, but this is just one thing I have no clue about.

Note: I have read SOME other posts about this thread that were not an exact answer or just didn’t help my problem because they were confusing.

all you have to do is to get the 3d position of the mouse. after that you can set it’s position to that 3d position