Why is aiming down sights wonky

I have a gun system with aim down sights but when i aim the gun goes out of the camera. Code

local viewmodel = game.Workspace:WaitForChild("MODEL")
local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
viewmodel.Parent = cam
local mouse = player:GetMouse()
local animation = script:WaitForChild("Hold")
local Humanoid = viewmodel.Humanoid
local Animation = Humanoid:LoadAnimation(animation)
local run = game:GetService("RunService")
Animation:Play()
local aiming = false
local posAIM = CFrame.new()
run.RenderStepped:Connect(function()
	viewmodel:SetPrimaryPartCFrame(cam.CFrame  * posAIM)
	if aiming then
		posAIM = posAIM:Lerp(cam.CFrame,0.2) --Goal CFrame (lower the number, lower the speed is)
	else
		posAIM = posAIM:Lerp(CFrame.new(), 0.1)           
	end
end)
mouse.Button2Down:Connect(function()
	viewmodel.PrimaryPart = viewmodel.Val.Aim
	aiming = true
end)
mouse.Button2Up:Connect(function()
	viewmodel.PrimaryPart = viewmodel.HumanoidRootPart
	aiming = false
end)

help please

1 Like

Can you post screenshots and/or GIFs

Oh i managed to fix the issue. The lerp starting was empty and the end result wasnt a end point it was the actual position thats why it went off.

1 Like