How to move turret on Y axis by mouse position?

So I’m making a Tank and I don’t know how to move tank turret by mouse position. I welded the turret. I know that I can use C0 but I don’t know how.

Also I tried this code

while wait() do
	local mousePosition = Mouse.Hit.p
	local Weld = Turret.Misc.Move.Weld
	Weld.C0 *= CFrame.Angles(0,mousePosition.Y,0)
end

It kinda worked but it is rotating only when I drag mouse on it and its not rotating correct. Any help will be appreciated.

Turret

1 Like