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 = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine
)
Cam.CFrame = Cam.CFrame * CFrame.Angles(0, math.rad(10), 0)
UIS.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E then
TS:Create(Humanoid,TI, {CameraOffset = Vector3.new(2.5,0,0)}):Play()
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame *CFrame.fromEulerAnglesXYZ(0, 0, math.rad(30))
end
if Key.KeyCode == Enum.KeyCode.Q then
TS:Create(Humanoid,TI, {CameraOffset = Vector3.new(-2.5,0,0)}):Play()
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame *CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-30))
end
end)
UIS.InputEnded:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E or Key.KeyCode == Enum.KeyCode.Q then
TS:Create(Humanoid,TI, {CameraOffset = Vector3.new(0,0,0)}):Play()
end
end)
first video is what I’ve got and the second is the desired effect I’m trying to achieve