Help with camera model rotation limits

I’m making a camera that looks at you when your spotted, however it looks weird when the camera faces down all the way so I want to put limits on it, the maximum x axis should be 50 on the cameras rotation

local function LookAt(Position)
	local lookatCframe = CFrame.lookAt(camera:GetPivot().Position, Position)
	local offsetCframe = CFrame.Angles(math.rad(0), math.rad(180), math.rad(-90))
	local cframe = lookatCframe * offsetCframe
	camCFrame.Value = cframe
end

nvm i fixed it : `local function LookAt(Position)
local lookatCframe = CFrame.lookAt(camera:GetPivot().Position, Position)
local offsetCframe = CFrame.Angles(math.rad(0), math.rad(180), math.rad(-90))
local cframe = lookatCframe * offsetCframe

local rx, ry, rz = (cframe - cframe.Position):ToOrientation()

local position = camCFrame.Value.Position
local clampedX = math.clamp(rx, 0, 0.6)
camCFrame.Value = CFrame.new(position) * CFrame.fromOrientation(clampedX, ry, rz)

end
`

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.