Hello, I am trying to limit the camera rotation to 30 degrees to right and 30 degrees to the left. So the player can only rotate their camera 30 degrees to each direction. But I can’t do it. I already tried some scripts, but none of them worked. I even searched in the forum, but I couldn’t find anything related. The most I got was this script that limits the rotation to 30 degrees in only one direction.

```
local minRotation = -30
local maxRotation = 30
local lastRotation = 0
game:GetService("RunService").RenderStepped:Connect(function()
local currentRotation = workspace.CurrentCamera.CFrame.LookVector
local angle = currentRotation:Dot(Vector3.new(1,0,0))
angle = math.deg(math.acos(angle))
if angle > lastRotation then
if angle > maxRotation then
angle = maxRotation
end
else
if angle < minRotation then
angle = minRotation
end
end
lastRotation = angle
local newRotaton = Vector3.new(math.cos(math.rad(angle)),0,math.sin(math.rad(angle)))
workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.p,workspace.CurrentCamera.CFrame.p + newRotaton)
end)
```

Current result:

https://gyazo.com/d55fb430175af08b83a143ef0a7ae65a