Aim script broken

Hi, I have been trying to figure this one out for a while with tonnes of different methods that all run into the same problem. The weapon doesn’t aim when to close to parts and the torso just spins. aimVid.wmv (3.1 MB)

Current Method code:

userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

-- rotate the torso
playerChar.HumanoidRootPart.CFrame = CFLookAt(playerChar.HumanoidRootPart.CFrame.Position, playerChar.HumanoidRootPart.CFrame.Position + V3New(camera.CFrame.LookVector.X, 0, camera.CFrame.LookVector.Z))

-- get the angles to add
local hitPoint = getHit(camera.CFrame.Position, camera.CFrame.LookVector * 100, {weaponTool, playerChar})
local targetCFrame = CFLookAt(aimPart.Position, hitPoint)
local relativeCFrame = aimPart.CFrame:ToObjectSpace(targetCFrame)
local x, y, z = relativeCFrame:ToOrientation()
local cX, cY, cZ = waistMotor.C0:ToOrientation()
x, y = x + cX, y+ cY

-- set the angles on the torso
waistMotor.C0 = CFrame.Angles(0, y, 0) * CFrame.Angles(x, 0, 0)

Any help at all would be much apricated!