Hey im making an fps but my aiming is snappy is there a way to fix this while being able to have the viewmodel be relative to the camera’s position?
script (very messy)
RunService.RenderStepped:Connect(function(step)
idle:Play()
if aim == false then
local camframe = game:GetService("Workspace").CurrentCamera.CFrame
script.Parent.FakeCamera.CFrame = camframe + camframe.LookVector * -0 + camframe.UpVector * -0 + camframe.RightVector * -0
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
local x,y,z = rotation:ToOrientation()
swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1)
script.Parent.FakeCamera.CFrame = script.Parent.FakeCamera.CFrame * swayOffset
lastCameraCF = workspace.CurrentCamera.CFrame
else
if Left1 == true and Right1 == false then
local camframe = game:GetService("Workspace").CurrentCamera.CFrame
script.Parent.Aim.L1.CFrame = camframe + camframe.UpVector * -0.03
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
local x,y,z = rotation:ToOrientation()
swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1)
script.Parent.Aim.L1.CFrame = script.Parent.Aim.L1.CFrame * swayOffset
lastCameraCF = workspace.CurrentCamera.CFrame
else
if Right1 == true and Left1 == false then
local camframe = game:GetService("Workspace").CurrentCamera.CFrame
script.Parent.Aim.R1.CFrame = camframe + camframe.UpVector * -0.03
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
local x,y,z = rotation:ToOrientation()
swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1)
script.Parent.Aim.R1.CFrame = script.Parent.Aim.R1.CFrame * swayOffset
lastCameraCF = workspace.CurrentCamera.CFrame
else
if Right1 == false and Left1 == false then
local camframe = game:GetService("Workspace").CurrentCamera.CFrame
script.Parent.Aim.CFrame = camframe + camframe.UpVector * -0.03
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
local x,y,z = rotation:ToOrientation()
swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1)
script.Parent.Aim.CFrame = script.Parent.Aim.CFrame * swayOffset
lastCameraCF = workspace.CurrentCamera.CFrame
else
if Left1 == true and Right1 == true then
local camframe = game:GetService("Workspace").CurrentCamera.CFrame
script.Parent.Aim.CFrame = camframe + camframe.UpVector * -0.03
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
local x,y,z = rotation:ToOrientation()
swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1)
script.Parent.Aim.CFrame = script.Parent.Aim.CFrame * swayOffset
lastCameraCF = workspace.CurrentCamera.CFrame
end
end
end
end
end
end)