Camera won't allow AlignOrientation to go upside down

I’m making a mouse-controlled plane system utilizing AlignOrientation and LinearVelocity. Problem is, when I move my mouse all the way downwards or upwards, it goes all crazy as shown in the video:

I want to be able to go upside down without any problem.

Here’s my code if you need it.

    local dir = (currentmouse.Hit.Position - cam.CFrame.Position).Unit
	local aim = CFrame.new(cam.CFrame.Position, cam.CFrame.Position + dir)
	local aimdirection = aim * CFrame.Angles(0,0,math.rad(clampAngle(roll + yawtween.Value))) -- this handles rolling left and right
	
 -- i tried to set a max angle going downwards and upwards here, didnt help

	local maxangle = 80
	
	local rx,ry,rz = aimdirection:ToOrientation()
	local xlimit = math.clamp(math.deg(rx),-70,70)
	local fromor = CFrame.fromOrientation(math.rad(xlimit),ry,rz)
	local aimdirectionfinal = CFrame.new(aimdirection.Position) * fromor
	
	ship.Important.Events.Orientation:FireServer(aimdirectionfinal)```

Can you test this code And Update me ?

local dir = (currentmouse.Hit.Position - cam.CFrame.Position).Unit
local aim = CFrame.new(cam.CFrame.Position, cam.CFrame.Position + dir)
local aimdirection = aim * CFrame.Angles(0,0,math.rad(math.clamp(roll + yawtween.Value, -maxangle, maxangle)))

local rx,ry,rz = aimdirection:ToOrientation()
local xlimit = math.clamp(math.deg(rx), -maxangle, maxangle)
local fromor = CFrame.fromOrientation(math.rad(xlimit),ry,rz)
local aimdirectionfinal = aimdirection * fromor

ship.Important.Events.Orientation:FireServer(aimdirectionfinal)

What is the difference in this code here? Makes things worse

This new code should correctly limit the rotation angle around the x-axis to a maximum of maxangle degrees in either direction because you were technically doing a mistake in the code

oh and btw don’t forget to initialize the maxangle

Not what I need it to do, I also want it to turn upside down without experiencing weird issues. The max angle was a temporary fix