Help with rotating turret on one axis

I’m currently trying to rotate a turret I’ve made using a localscript and I’ve got some working code although it rotates on the wrong axis. I’ve tried changing the values around but it hasn’t fixed it. Any help with this would be greatly appreciated

Pivot1.CFrame = CFrame.new(Pivot1.Position,Vector3.new(Mouse.hit.Position.X, Pivot1.Position.Y, Mouse.hit.Position.Z)) * CFrame.Angles(0,math.rad(90),0)

try removing the cframe.angles part

that doesn’t change anything, I just put it there because it was facing the wrong way

well what axis is it turning on
im assuming you want it turning on the y axis

Its turning on the y right now but I need it to turn on the x

try this out
Pivot1.CFrame = CFrame.lookAt(Pivot1.Position, Vector3.new(Mouse.Hit.Position.X, Mouse.Hit.Position.Y, Pivot1.Position.Z))

has no difference. I’ve found that switching the axis to (Pivot2.Position, Vector3.new(Mouse.Hit.Position.Z, Mouse.Hit.Position.Y, Pivot2.Position.X)) sort of works, but it starts to go some other way if it goes under 90

local turrethead = -- path to turret head
local targetpos = -- ur target
local initialpos = turrethead.Position

-- a loop
turrethead.CFrame = CFrame.new(initialpos,Vector3.new(initialpos.X,targetpos.Y,initialpos.Z)

that’s the exact same thing as the code I was using in the first plae

I didnt red your post.