How to make an object placement system that follows your mouse on only one axis?

Hello there!

I was wondering on how to make a system where it follows your mouse, but only one axis.

https://gyazo.com/40302fe62dff94e812d4d56b46752b21

I want it to follow the mouse on the Z axis, and make it so when you click it drops it, or when you hold it down, it keeps placing. Since the objects that I’ll be placing won’t be anchored since I want them to fall down.

If you have any ideas, please let me know, thank you.