I have never scripted any form of aircraft or vehicle before. I’ve been searching through forums and I found a few ways of making an aircraft fly. The only issue is the aircraft is not what I want, right now it’s more of a bouncing ping pong ball to say the least. Strange functionality. I have looked into some free model airplanes seeing how they’re scripted and they all include something about CFrame.fromEulerAnglesXYZ. Could someone give me a clear and simple explanation of what it does and how I can make my aircraft less of a Bouncing Saucer? Thanks!
- SCRIPT
local rs = game:GetService("RunService")
local VehiclePrompt = script.Parent.EnterVehiclePrompt
local Occupied = script.Parent.Occupied
local Occupant = script.Parent.Occupant
local AircraftCamera = script.Parent.AircraftCamera
local AircraftEventFolder = game.ReplicatedStorage:FindFirstChild("Aircrafts")
local TemporaryCell = game.Workspace.AircraftEntryCharacterPlacement
local Events = {
["Enter"] = AircraftEventFolder:FindFirstChild("Enter")
}
local VehicleSeat = script.Parent.VehicleSeat
local BG = VehicleSeat.BodyGyro
local BGDefault = BG.Default
local BP = VehicleSeat.BodyPosition
local BPDefault = BP.Default
local BV = VehicleSeat.BodyVelocity
local BVDefault = BV.Default
local maxspeed = VehicleSeat.MaxSpeed
maxspeed = 200
local value1 = 0
BG.CFrame = VehicleSeat.CFrame
BP.Position = VehicleSeat.Position
VehiclePrompt.Triggered:Connect(function(player)
Events.Enter:FireClient(player,AircraftCamera)
local Char = player.Character
local HRP = Char.HumanoidRootPart
local Humanoid = Char.Humanoid
wait(1)
Humanoid.JumpPower = 0
VehicleSeat:Sit(Humanoid)
BG.MaxTorque = BGDefault.Value
BP.MaxForce = BPDefault.Value
Occupied.Value = true
Occupant.Value = player.Name
while Occupied.Value == true do
wait()
if VehicleSeat.Throttle == 1 then
if value1 < maxspeed then value1 = value1 + 1 end
BV.velocity = VehicleSeat.CFrame.lookVector * value1
end
if VehicleSeat.Throttle == 0 then
value1 = 0
BV.velocity = VehicleSeat.CFrame.lookVector * value1
end
if VehicleSeat.Throttle == -1 then
if VehicleSeat.Steer == -1 then
BP.Position = VehicleSeat.CFrame * Vector3.new(0,10,0)
end
end
if VehicleSeat.Throttle == -1 then
if VehicleSeat.Steer == 0 then
BP.Position = VehicleSeat.CFrame * Vector3.new(0,-10,0)
end
end
if VehicleSeat.Steer == 1 then
BG.CFrame = BG.CFrame * CFrame.fromEulerAnglesXYZ(0,-.1,0)
end
if VehicleSeat.Steer == -1 then
if VehicleSeat.Throttle == 0 or VehicleSeat.Throttle == 1 then
BG.CFrame = BG.CFrame * CFrame.fromEulerAnglesXYZ(0,.1,0)
end
end
end
end)
Occupied.Changed:Connect(function()
if Occupied.Value == true then
VehiclePrompt.Enabled = false
elseif Occupied.Value == false then
VehiclePrompt.Enabled = true
end
end)
- LOCAL SCRIPT
local TS = game:GetService("TweenService")
local AircraftEventFolder = game.ReplicatedStorage:FindFirstChild("Aircrafts")
local Cam = workspace.CurrentCamera
local Events = {
["Enter"] = AircraftEventFolder:FindFirstChild("Enter")
}
Events.Enter.OnClientEvent:Connect(function(AircraftCamera)
local AircraftTweenGoal = {}
Cam.CameraType = "Attach"
AircraftTweenGoal.CFrame = AircraftCamera.CFrame
local TI = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
local AircraftTween = TS:Create(Cam,TI,AircraftTweenGoal)
AircraftTween:Play()
wait(TI.Time)
Cam.CameraSubject = AircraftCamera
end)
Here is a video of it “flying”.