Why is this happening with my helicopter?

Why is this happening with my chopper?

	if Keys.E then
				ExpectedSpeed = Vector3.new(ExpectedSpeed.X,math.clamp(Force.Velocity.Y + 1,1/math.pi,15),ExpectedSpeed.Z)
				local xD = 0
				
			
				print(Xrotation)
				if tick() - lastT > 0.2 then
					lastT = tick()
					ExpectedGyroCFrame = CFrame.new(Mainpart.Position,Mainpart.Position) * CFrame.Angles(math.rad(Xrotation),0,math.rad(Xrotation))
				end
				
			else
				ExpectedGyroCFrame = CFrame.new(Mainpart.Position,Mainpart.Position)
				ExpectedSpeed = Vector3.new(ExpectedSpeed.X,math.sin(tick()),ExpectedSpeed.Z)
			end
			if Keys.W then
				
				
				Speed = math.clamp(Speed + 0.1,0,120 --[[maxspeed]])
				local yes = Mainpart.CFrame.LookVector.Unit * Speed
				ExpectedSpeed = Vector3.new(yes.X,ExpectedSpeed.Y,yes.Z)
				ExpectedGyroCFrame = CFrame.new(Mainpart.Position,Mainpart.Position) * CFrame.Angles(math.rad(-10),0,0)
			else
		
				ExpectedSpeed = Vector3.new(0,ExpectedSpeed.Y,0)
			end
			if Keys.A then
				local yes = Mainpart.CFrame.RightVector.Unit * Speed
				--ExpectedSpeed = Vector3.new(-yes.X,ExpectedSpeed.Y,-yes.Z)
				Athingy += 0.5
				ExpectedGyroCFrame = CFrame.new(Mainpart.Position,Mainpart.Position) * CFrame.Angles(0,math.rad(Athingy),math.rad(12))
			end
			Gyro.CFrame = ExpectedGyroCFrame
			game:GetService('TweenService'):Create(Force,TweenInfo.new(0.6),{Velocity = ExpectedSpeed}):Play()
		--	Force.Velocity = ExpectedSpeed
		end

The thing is, the ‘ExpectGyroCFrame’
Causes this to happen:
https://gyazo.com/d9f2136abdc8416b453435a7e68d1928
Any idea?

It looks like some CFrame or Vector3 in your code is becoming NaN. This causes the assembly to teleport to a plane of non-existence, which subsequently breaks everything in the assembly.

Check your calculations. Make sure you are not dividing by zero anywhere.

1 Like