#Plane scripting help

1 messages · Page 1 of 1 (latest)

pseudo mango
#
local rs = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")


-- others
local seat = nil
local fuselage = nil
local vectorForce = nil
local attachment = nil

-- Flight variables
local thrust = 0 

local groundVelocity = nil
local airVelocity = nil

local drag = 0
local lift = 0


hum.Seated:Connect(function(isSeated, seatPart)
    seat = seatPart
    fuselage = seat.Parent:WaitForChild("Fuselage")
    
    vectorForce = Instance.new('VectorForce', fuselage)
    attachment = Instance.new('Attachment',fuselage)
    vectorForce.Attachment0 = attachment
    attachment.WorldOrientation = Vector3.zero
    
    
    rs.PostSimulation:Connect(function(deltaTimeSim: number) 
        if uis:IsKeyDown(Enum.KeyCode.E) then thrust = 2000 * deltaTimeSim end
        if uis:IsKeyDown(Enum.KeyCode.Q) then thrust = -2000 * deltaTimeSim end
        
        vectorForce.Force += Vector3.new(0, 0, -thrust)
    end)
end)
#

Right now i'm using Suphi's thrust code but I reckon I'll change it so that thrust = maxthrust * throttle, 0 <= throttle <= 1, and is increased/decreased by pressing E/Q