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
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