View model glitches when trying to lerp the position

I’m creating my own gun system, and I was creating an aiming feature on the guns. my only issue Is looks glitchy when aiming and I’m not sure how to fix it. Any help would be appreciated

Video of whats happening:

Code:


if Aiming then
			local Offset2 = CurrentVM.Weapon.AimPoint.CFrame:ToObjectSpace(CurrentVM.PrimaryPart.CFrame)
			AimCF = AimCF:Lerp(Offset2, 0.05)
		else
			local Offset2 = CFrame.new()
			AimCF = AimCF:Lerp(Offset2, 0.05)
		end
		
		if not Aiming then
			CurrentVM:SetPrimaryPartCFrame(Camera.CFrame * VMConfig.Offset * AimCF)
		else
			CurrentVM:SetPrimaryPartCFrame(Camera.CFrame * AimCF)
		end

By the way don’t use :SetPrimaryPartCFrame, use :PivotTo() instead

1 Like

well 1 this is in a if aiming so It cancels out not aiming check

if not Aiming then
			CurrentVM:SetPrimaryPartCFrame(Camera.CFrame * VMConfig.Offset * AimCF)
		else
			CurrentVM:SetPrimaryPartCFrame(Camera.CFrame * AimCF)
		end

2 if you move it out of the if aiming. The else of the if not aiming it says with no offset which causes it to go to no offset really quick then lerp to aiming

CurrentVM:SetPrimaryPartCFrame(Camera.CFrame * AimCF)

1 Like

If this works or not please let me know to keep helping you!

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