Moving model's CFrame

For my first person shooter, I’m making a system to aim down the gun’s sights. The gray part seen above the gun’s stock is named “AimPart”. Setting your camera’s CFrame to the AimPart’s CFrame makes it look like you’re aiming down the gun’s sights.

Right now, the rig’s HumanoidRootPart is “attached” to the camera using this piece of code in a RenderStepped loop:

	Gun:PivotTo(cam.CFrame * CameraOffset) -- CameraOffset is equal to CFrame.new(0, 0, 0)

I plan on using CameraOffset to offset the rig’s CFrame when it’s attached to the camera, which aligns the camera with the AimPart. I need help figuring out what to set CameraOffset equal to when the player is aiming down sights.

Here is my current code:

	Gun:PivotTo(cam.CFrame * CameraOffset)
	
	if uis:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then
		CameraOffset = Gun.AimPart.CFrame - Gun.PrimaryPart.CFrame -- this is giving an error
	else
		CameraOffset = CFrame.new(0, 0, 0)
	end