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