I’m not really experience when it comes CFrame, I don’t really understand how I would be able to clamp `(-45, 45)`

on a `CFrame.Angle()`

since the out of this are all 1’s and 0.

```
charView.MouseMoved:Connect(function(X, Y)
if holdInDisplay == false then return end
if currentX or currentY then
camera.CFrame = (camera.CFrame.Rotation * CFrame.Angles(-(Y-currentY) * 0.01, 0, 0)) * CFrame.new(0, 0, 6.5)
clonedChar.PrimaryPart.CFrame *= CFrame.Angles(0, (X-currentX) * 0.01, 0)
end
currentX = X
currentY = Y
end)
```

The camera is from the `ViewPortFrame`

.

2 Likes

detect if the why angle is -45 or 45 and if its over set it to -45 or 45

```
if currentY > 45 then
currentY = 45
else
if currentY < -45 then
currentY = -45
end)
end)
```

this isnt the best fix but its something to hopefully give u the right direction

That won’t work since that’s a mouse location.

ah i see try using raycast for that then

Nvm I found the answer all I need was to check the movement direction of the mouse and the rotation of the X axis of the camera.

##
Code

```
function newAngle(Y)
return (Camera.CFrame.Rotation * CFrame.fromEulerAnglesXYZ(-math.asin((Y-currentY) * 0.01), 0, 0)) * CFrame.new(0, 0, 6.5)
end
script.Parent.ViewportFrame.MouseMoved:Connect(function(X,Y)
if HoldInDisplay == false then return end
if currentX and currentY then
local x, y, z = Camera.CFrame:ToEulerAnglesXYZ()
if x > -1 and (Y-currentY) > 0 then
Camera.CFrame = newAngle(Y)
elseif x < 1 and (Y-currentY) < 0 then
Camera.CFrame = newAngle(Y)
elseif x > 1 then
Camera.CFrame = CFrame.fromEulerAnglesXYZ(1, 0, 0) * CFrame.new(0, 0, 6.5)
elseif x < -1 then
Camera.CFrame = CFrame.fromEulerAnglesXYZ(-1, 0, 0) * CFrame.new(0, 0, 6.5)
end
ClonedChar.PrimaryPart.CFrame *= CFrame.fromEulerAnglesXYZ(0,(X-currentX)*.01,0)
end
currentX = X
currentY = Y
end)
```

1 Like