How to make a part only follow a player on ONE axis

Hey developers, quick question on how id make a part follow the player on one axis. like a turret. only moves side to side not up down, if you get what i mean. well more like 2 axes if i say it like that but you get what im saying

Id like it to also be global lol so everyone sees whos its facing

remove the axis you don’t want when doing your calculation. for example if you want a turret to only rotate on the y axis, then use CFrame.lookAt but make sure the y difference between the points is always zero:

yOnly = Vector3.one - Vector3.yAxis
yawRotation = CFrame.lookAt(position * yOnly, target * yOnly)