Problems rotating turret

Hello, so I have this code that makes a turret face the mouse position, but for some reason its really glitchy and I dont know why.

https://gyazo.com/0417252d6b51be82deb221fba7feb60c

Script:

local event = script.Parent.Rotate
local mesh = script.Parent.MeshPart

local function getCFrame(position, lookAt)
	
    local lookVector = (position - lookAt).Unit 
    local modelUpVector = Vector3.new(0, 1, 0)
    local rightVector = lookVector:Cross(modelUpVector)
    local upVector = rightVector:Cross(lookVector)

	return CFrame.fromMatrix(position, rightVector, upVector)
	
end

event.OnServerEvent:Connect(function(plr, pos)
	print("Fired")
	mesh.CFrame = getCFrame(mesh.Position, -pos)
end)
	

If the turret’s FrontFace is the face which you want to turn towards the mouse, you can just use CFrame.new(position, lookAt) constructor to make it look there.

That one is deprecated

30chars

Kindly try using the function provided by @EgoMoose