Viewmodel lagging behind (again)

i’m trying to make a viewmodel sway for my fps framework for the 31st time and i still have no idea what im doing

this is my code, taken from this post:

local mult = 1
local swayOffset = CFrame.new()
local lastCameraCF = workspace.CurrentCamera.CFrame

local function renderloop()
	if gun then
		gun.PrimaryPart.CFrame = cam.CFrame * swayOffset
		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)
		gun.PrimaryPart.CFrame = gun.PrimaryPart.CFrame * swayOffset
		lastCameraCF = workspace.CurrentCamera.CFrame
	end
end

runservice:BindToRenderStep('swayLoop', 1, renderloop)

it works, but it lags behind a bit

could anyone help me out here? i’ve been struggling with this for months now…
if you need any more information i’ll provide

i fixed it within a minute of posting this how am i so stupid :skull:

runservice:BindToRenderStep('swayLoop', Enum.RenderPriority.Camera.Value, renderloop)