Gun sights not lining up when looking up and down

I’m making a FPS/3rd person gun, and I’m welding a part to the HumanoidRootPart through Motor6D and then copying the values of the head CFrame. The fake arms are welded to this part (gun welded to arms, and I’m using one of the head moving codes algorithms from the forum to move it up and down, but when I do this, the rear sight can’t be seen anymore when I move up and down.
Should look like that


But ends up like this if I move up

I had originally had it welded directly to the head before but switched it because I thought this was the issue. It didn’t fix the issue and had no effect on anything.

Here’s the code I use for moving the arms up and down:

mouse.Move:connect(function(pos)
	local CFNew, CFAng, CFtoObjectSpace = CFrame.new, CFrame.Angles, CFrame.new( ).toObjectSpace
	local asin, pi, hpi = math.asin, math.pi, math.pi / 2
	local Root, Neck, Humanoid, Camera = player.Character:FindFirstChild("HumanoidRootPart"), player.Character:FindFirstChild("Neck", true), player.Character:FindFirstChild("Humanoid"), workspace.CurrentCamera
    if Root and Neck and Humanoid and Camera.CameraSubject then
        local R6 = Humanoid.RigType == Enum.HumanoidRigType.R6
		Neck.MaxVelocity = 100
        if Camera.CameraSubject.Parent == player.Character then
            local CameraDirection = CFtoObjectSpace(Root.CFrame, Camera.CFrame).lookVector.unit
			moveweld.C0 = CFNew(moveweld.C0.p) * CFAng(0, -asin(CameraDirection.x), 0) * (R6 and CFAng(-hpi + asin(CameraDirection.y), 0, pi) or CFAng(asin(CameraDirection.y), 0, 0))
			Neck.C0 = CFNew(Neck.C0.p) * CFAng(0, -asin(CameraDirection.x), 0) * (R6 and CFAng(-hpi + asin(CameraDirection.y), 0, pi) or CFAng(asin(CameraDirection.y), 0, 0))
        else
            Neck.C0 = R6 and CFNew(Neck.C0.p) * CFAng(-hpi, 0, pi) or CFNew(Neck.C0.p)
        end
    end
	
end)

Any ideas on why this is happening, or how to fix it?

2 Likes

I figured out the issue - set the CameraSubject to the head and it doesn’t do that anymore

1 Like