Robot's Head Look At Certain Object On The Z Axis

what i want to do is make this

to something like this
Untitled

i dont have the code doe but i tried making it with this piece of code

CFrame.new(0, ZOffset, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0)

Give this a read:

Check the Facing toward a point section.
You can just rotate it on the axes you need.

yes i did do that but it didnt worked

Are you just CFraming it once, or do you keep checking to see where it should be ‘looking’?
Try giving us the entire script rather than just one line.

its in run service (meaning keep checking) and i dont have the script becuz i accidently non purposly deleted it