I’ve got a script that gives a viewmodel sway when the player is walking, when not walking it has a slower sway. The problem is I want it to lerp to the position when standing still but the weapon slowly falls and clips into the floor.
–Example Video
Video (3).wmv (2.1 MB)
–Snippet of Script
local SetViewPosition = RunService.RenderStepped:Connect(function (dt)
local CurrentCFrame = V_Viewmodel:GetPivot()
if HumRoot.AssemblyLinearVelocity.Magnitude < 1 then
t=0
local DefaultGunShake = math.sin(tick() * 2) * 0.05
local TargetCFrame = Camera.CFrame * CFrame.new(0 + DefaultGunShake,-4.5 + DefaultGunShake, 0.55)
local NewCFrame = CurrentCFrame:Lerp(TargetCFrame, 0.9)
V_Viewmodel:PivotTo(NewCFrame)
else
t += dt
local GunShake = math.sin(t * 5) * 0.1
V_Viewmodel:PivotTo(Camera.CFrame * CFrame.new(0 + GunShake,-4.5 + GunShake, 0.55))
end
end)