Need help with plane

I’m making a plane, but there’s 2 problems. First problem is, the BodyVelocity I use to make it move forwards/backwards completely ignores gravity. I’m not sure how to fix that. Second, I’m not sure which body mover to use to rotate the plane to make it take off. I’ve tried AlignOrientation, but that didn’t give me the results that I wanted.

Code
--[[
	Main
	
	Author: zCrxtix
	Description: Main script to fly the plane
]]

local seat = script.Parent
local plane = script.Parent.Parent
local base = plane.Base

local remotes = plane.Remotes
local getmouse = remotes.GetMouse

local bv = base.BodyVelocity
local av = base.AngularVelocity
local ao = base.AlignOrientation

local throttle = 0
local incline = 4
local stall = false

local max_speed = 1.5 -- what the final throttle result gets divided by so it doesnt go crazy fast

---------------------------------------------------------------------------------------------------
local orig_cframe = base.CFrame

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant ~= nil then 
		local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
		if not player.PlayerGui:FindFirstChild("ClientControl") then
			script.ClientControl:Clone().Parent = player.PlayerGui
		end
		seat:SetNetworkOwner(player)
	end
end)

while true do
	if seat.Occupant then
		local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
		seat:SetNetworkOwner(player)
		
		local sthrottle = seat.Throttle
		local steer = seat.Steer

		if sthrottle == 1 and throttle < 100 then
			task.spawn(function()
				throttle += 1
				task.wait(0.05)
			end)
		elseif sthrottle == -1 and throttle >= -20 then
			task.spawn(function()
				throttle -= 1
				task.wait(0.05)
			end)
		elseif steer == 1 then
			task.spawn(function()
				steer += 1
				task.wait(0.05)
			end)
		elseif steer == -1 then
			task.spawn(function()
				steer -= 1
				task.wait(0.05)
			end)
		end
		
		local success, e, q = pcall(function() return remotes.GetInput:InvokeClient(player) end)
		if e then
			task.spawn(function()
				incline += 1
				task.wait(0.05)
			end)
		elseif q then
			task.spawn(function()
				incline += 1
				task.wait(0.05)
			end)
		end
		
		if throttle >= 70 then
			--can take off
		else
			if throttle <= 25 then
				--stall if in air, otherwise make it so you cant take off
			end
		end
		av.AngularVelocity = Vector3.new(0,0,-steer)
		bv.Velocity = seat.CFrame.LookVector * throttle/max_speed
	end
	task.wait()
end

https://developer.roblox.com/en-us/api-reference/class/VectorForce

https://developer.roblox.com/en-us/api-reference/class/AngularVelocity

Using the AngularVelocity, the plane just spins forever. I only want to make it go up steadily.

That sounds like your problem. If you’ve actually read the description, it says it applies torque such that the part maintains a constant angular velocity. Either you set the goal ω too high or you aren’t using it correctly, or both

The goal is set to 1. No matter what I put it at, it still rotates in a circle forever.

Doesn’t help.

You clearly don’t know how to use it, so let me explain:

Angular velocity (ω) is like linear velocity (v). They’re both derivatives; linear velocity is the derivative of position and angular velocity is the derivative of orientation.
A velocity that’s not zero means the position is always changing. This is why parts with velocity are constantly moving. Likewise, an angular velocity that’s not zero means the part is constantly rotating.
Angular velocity in Roblox is measured in radians per second (rad/s). ~3.14 radians is 180 degrees. You said that you set the goal to 1, which means your plane will rotate ~53 degrees per second.
You set the angular velocity to 1 rad/s and kept it at that without changing, which is why the plane will never stop rotating. Angular velocity needs to be zero if you want the plane to stop rotating.
So the correct way to use it is to toggle between 0 and the angular velocity depending on when you want the plane to spin. For example, when the player pitches the plane, you set ω to 1; and when the player releases the key you set it back to 0.
If the rotation is too rigid, try tweaking the MaxTorque, or you can alternatively add another derivative by tweening the velocity with TweenService, which is essentially angular acceleration

btw if you don’t know what derivative means, read this kid-friendly tutorial: Introduction to Derivatives

3 Likes