Hello! I was working on an fps system and my viewmodel started having some issues I have never had before. This effect is like whenever you use :lerp() in a RenderStepped function.
I have looked at another forum post about the same issue, but the solution from that post didn’t work. I have also tried the code but just setting the viewmodel CFrame to the camera CFrame. But it still has the effect. Here is the code that is making the viewmodel move.
local function UpdateViewmodelTransform(dt) --// Bound to render step
viewmodel:PivotTo(cam.CFrame)
if hum ~= nil then
bobSpring:shove(Vector3.new(sin(tick() * (2.5 * pi)) * .5, (.2 * cos(2 * tick() * (2.5 * pi))) * .5, 0) / 10 * character.HumanoidRootPart.Velocity.Magnitude / 10)
viewmodel.HumanoidRootPart.CFrame = viewmodel.HumanoidRootPart.CFrame:ToWorldSpace(CFrame.new(bobSpring:update(dt).X, bobSpring:update(dt).Y, 0))
local MouseDelta = game:GetService("UserInputService"):GetMouseDelta()
swaySpring:shove(Vector3.new(-MouseDelta.X / 200, MouseDelta.Y / 100, 0))
local updatedSway = swaySpring:update(dt)
viewmodel.HumanoidRootPart.CFrame *= CFrame.new(updatedSway.X, updatedSway.Y, 0)
end
end
The only slight work around is moving the script to StarterCharacterScripts and running, then putting it back in StarterPlayerScripts and running it. This fixes the problem. But if I stop and run again, the issue will come back.
Any help is appreciated!
EDIT: I fixed the problem, I forgot to wait until the game was fully loaded before initializing the viewmodel.