I have made a leaning system for my fps viewmodels. I have the animations and stuff to make it look like the player is leaning, but the problem is, whenever I rotate the camera, it rotates the player’s character in weird way. Here is my code:
UIS.InputBegan:Connect(function(input, process)
if not process then
if input.KeyCode == Enum.KeyCode.Q then --//Lean Right
leanState = 1
lean1 = player.Character.Humanoid:LoadAnimation(script.AnimSaver.LeanLeft)
lean1:Play()
elseif input.KeyCode == Enum.KeyCode.E then --// Lean Left
leanState = 2
lean2 = player.Character.Humanoid:LoadAnimation(script.AnimSaver.LeanRight)
lean2:Play()
end
end
end)
UIS.InputEnded:Connect(function(input, process)
if not process then
if input.KeyCode == Enum.KeyCode.Q then --//Lean Right
leanState = 0
lean1:Stop()
elseif input.KeyCode == Enum.KeyCode.E then --// Lean Left
leanState = 0
lean2:Stop()
end
end
end)
runServ.RenderStepped:Connect(function()
if leanState == 1 then
CameraMain = CameraMain:lerp(CFrame.new(-3,0,0)*CFrame.Angles(0,0,math.rad(10)),.1)
end
if leanState == 2 then
CameraMain = CameraMain:lerp(CFrame.new(3,0,0)*CFrame.Angles(0,0,math.rad(-10)),.1)
end
end)
Any help would be greatly appreciated!