Viewmodel partially lagging behind when moving?

I set the CFrame of the viewmodel every frame with RunService.RenderStepped.
Visually, it is perfectly fine, but the problem is when I reference the CFrame of any basepart within the viewmodel in a script.

It is pretty difficult to explain, so this is what it looks like:


In the video, you can see that the move tool visuals lag behind when the gun moves in any way.
(Using the move tool was just to demonstrate the lag. The main problem with this is that bullets and laser sights also lag behind when moving.)

The code to position the viewmodel is essentially just this:

viewmodel:PivotTo(camera.CFrame * offsets)

And this is how the viewmodel is set up


Mostly everything is attached to “Main” with WeldConstraints or Motor6Ds

The viewmodel itself is created on the server and is parented inside a folder inside the workspace when equipped. This is different from the more common way to do viewmodels, where it is created on the client and is a child of the camera. However, I have also tried this more common method and still had the same lag problem.

I am completely stumped and can not find any similar problems anywhere else. Any help is appreciated, thank you!

I’d look into using RunService:BindToRenderStep instead of RunService.RenderStepped, because it has an option to bind at a custom priority. Without seeing your scripts I’m guessing your loops for updating bullets or laser sights are running before your view model updates, causing them to be a frame behind.

1 Like

The viewmodel on server maybe make the lag, you should weld the muzzle part with the gun so its stick to the gun without lagging

1 Like

use .Stepped instead of .RenderStepped because setting the cframe of the viewport before the physics simulation could cause inconsistencies with any parts or attachments connected to it

1 Like

I mentioned in the post that I have already tried having the viewmodel on the client, and it does not fix the lag

.Stepped makes the entire viewmodel lag behind movement as it is not synced with the player’s framerate

I tried some stuff with BindToRenderStep but I could not achieve a good result, although I have never used BindToRenderStep so I could be using it incorrectly.

But the bullet and laser sight code is not the problem. Everything lags behind the viewmodel. In the video, it shows how Roblox’s built-in move tool even lags behind.

The problem was actually not related to anything lagging behind the gun, it was something with my recoil code. I just got confused because Roblox’s move tool was lagging behind, but it actually just does that with everything.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.