Clamp Rotation on neck Motor6D?

I have a custom camera script that aligns the camera cframe with the head cframe to create a natural bobble effect.

I need to clamp the neck motor6d so that the player’s camera (technically the head of the player rig) cannot look farther than directly down and directly up, but I can’t figure out how to achieve this.

I tried a lot of different ways such as creating a temporary cframe and using math.rad to clamp those values and then apply that to the neck motor6d but everything bugs out like crazy and I haven’t gotten close

this is the code that controls the camera

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local camera = game.Workspace.CurrentCamera
local head = char:FindFirstChild("Head")
local newCF, newCFangles = CFrame.new, CFrame.Angles
local rad, deg, clamp = math.rad, math.deg, math.clamp

while task.wait() do
	local mDelta = uis:GetMouseDelta()
	char.PrimaryPart.CFrame = char.PrimaryPart.CFrame * newCFangles(0, rad(clamp(mDelta.X, -125, 125)) / 5, 0):Inverse()
	camera.CFrame = head.CFrame
	
	local neckMotor = char:FindFirstChild("Torso"):FindFirstChild("Neck")
	neckMotor.C0 = neckMotor.C0 * newCFangles(rad(mDelta.Y) / 5, 0, 0)
end