local gunhorizontalaim = script.Parent.Parent.Direction

-- make an aim up function too

function findtarget()
	local dist = script.Parent.Parent.Configuration.AgroRange.Value
	local target = nil
	for i, v in pairs(game.Players:GetChildren()) do 
	local torso = v.Character:findFirstChild("LowerTorso")
	local master = script.Parent.Parent.Parent.Master.Value
	if v.Character.Name ~= master and torso then 
		if ((gunhorizontalaim.Position - torso.Position).Magnitude < dist) then
		dist =  (gunhorizontalaim.Position - torso.Position).magnitude 
		target = torso
		end
	end
	end
	return target
end


while wait(1) do 
	local torso = findtarget()
	if torso then 
		gunhorizontalaim.CFrame = CFrame.new(gunhorizontalaim.Position , torso.Position)
		wait(.1)
		print(gunhorizontalaim.CFrame)
	end
end

I have a hingeconstraint "Servo" in the Direction part and all i have to do is to apply a targetAngle and it turns towards that angle, the angle supposed to be aim at where target is. Also i want to make sure that that angle it is turning to is relative to its position cause that turret im putting it in a plane or smth and that plane will also be on the move. Is there a way to change CFrame to angles? The angle turns horizontally.