Problem with angles trying to limit the rotation of a plane

Hello devoforum, I am trying to limit how up a plane can rotate. The problem is the angle, it keeps bouncing:

https://gyazo.com/5df7765bc0f8e3a5ffc625c807aa3477
https://gyazo.com/896e5d05e4359279bea6d8c868ee27b1

This is the code I am using:

		local oriEntation = planeModel.Body.Orientation.X
		local minMax = math.clamp(oriEntation, -55, 55)
		
		if minMax == oriEntation then
			local goDir = planeModel.Body.CFrame.LookVector
			local mousePosition = GetMouseHit(workspace)
			local velMaxF = Vector3.new(400000, 400000, 400000)
			local bGyroMaxT = Vector3.new(900000, 900000, 900000)
			local bGyroD = planeModel.Configs.Maneuvrability.Value
			
			onEvent:FireServer(mousePosition, planeSpeed, goDir, planeModel.Body, velMaxF, bGyroMaxT, bGyroD)
		elseif minMax == 55 then
			planeModel.Body.CFrame = CFrame.new(planeModel.Body.Position) * CFrame.Angles(math.rad(54), math.rad(planeModel.Body.Orientation.Y), math.rad(planeModel.Body.Orientation.Z))
		elseif minMax == -55 then
			planeModel.Body.CFrame = CFrame.new(planeModel.Body.Position) * CFrame.Angles(math.rad(-56), math.rad(planeModel.Body.Orientation.Y), math.rad(planeModel.Body.Orientation.Z))
		end

Thanks for reading.

I’m not completely sure on how this stuff works or if I’m correct, but what I assume is happening is it gets to a certain angle then the plane corrects itself by turning lower. This is what’s creating your effect of correcting itself over and over again. I think you need to find a way to Max the angle itself and stop it from turning instead of correcting when it goes over.

1 Like

I figured out the problem. When setting the position iof the part it gets glitched. Is there any way to set the angles without setting the position?