Help needed with leaning system/camera rotation

I’m currently trying to create a leaning system for my gun system although I’m having a bit of trouble with the rotation part. I’ve tried fixing it but its either not worked or has rotated on some other axis.

this is the script

local Char = script.Parent

local Cam = game.Workspace.CurrentCamera

Cam.CameraType = Enum.CameraType.Scriptable

local Humanoid = Char:WaitForChild(“Humanoid”)

local UIS = game:GetService(“UserInputService”)

local TS = game:GetService(“TweenService”)

local TI =




Cam.CFrame = Cam.CFrame * CFrame.Angles(0, math.rad(10), 0)


if Key.KeyCode == Enum.KeyCode.E then

TS:Create(Humanoid,TI, {CameraOffset =,0,0)}):Play()

workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame *CFrame.fromEulerAnglesXYZ(0, 0, math.rad(30))


if Key.KeyCode == Enum.KeyCode.Q then

TS:Create(Humanoid,TI, {CameraOffset =,0,0)}):Play()

workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame *CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-30))




if Key.KeyCode == Enum.KeyCode.E or Key.KeyCode == Enum.KeyCode.Q then

TS:Create(Humanoid,TI, {CameraOffset =,0,0)}):Play()



first video is what I’ve got and the second is the desired effect I’m trying to achieve

CFrame.fromEulerAnglesXYZ(0, 0, math.rad(30))
Have you tried playing around with which angle you set, either the X, Y or Z axis.

If it instantly changes by something like 90 degrees you may need to add or subtract that angle from your calculation. Something like math.rad(-30 + 90) and math.rad(30+90).

I’ve tried changing the angles around and I haven’t had anything work so far.

1 Like