This is what I’m trying to achieve:

As you can see, the camera is unable to rotate past a certain point; I’m having some troubles with this.

I was able to recreate, and get this to work, but only if the player isn’t looking toward the spot where it breaks (This is a video of it working)

At a certain point, the Y orientation of the camera (in degrees) flips to negative and starts descending:

This is a problem for me, because I’m subtracting and adding onto the current Y rotation to get the min and max for the clamp:

```
local clamped_Y = math.clamp(math.deg(y), math.deg(old_y) - 35, math.deg(old_y) + 35)
```

Imagine you are facing 155 degrees, add 35, that’s 190, which is PAST the point at 180 where it flips to -180 and it breaks.

Because the Max is not the “correct” number, and even if it was, the max would be less than min. (which is not good!!)

Hopefully I explained that competently.

Here’s the full code:

```
local _, old_y = cam_module.camera.CFrame:ToOrientation()
local function clamp_camera()
local x, y, z = cam_module.camera.CFrame:ToOrientation()
local clamped_Y = math.clamp(math.deg(y), math.deg(old_y) - 35, math.deg(old_y) + 35)
cam_module.camera.CFrame = CFrame.new(cam_module.camera.CFrame.Position) * CFrame.fromOrientation(x, math.rad(clamped_Y), z)
end
```

And for anyone wondering, below that, I check if the player presses E, if so, I set the old Y again, then bind the “clamp_camera” function to RenderStepped.

I have tried using the code that a user suggested in this post; it did some weird stuff to say the least.

Anyway, is there any fix for this? I would love some guidance on this. Thanks for reading.