How to Make a Plane/Optional Features
These are some awesome option features you can add to your plane once you're done with it.
Bombing
If you want to be able to bomb, you need to do several things with the plane.
First, you must make a bomb. Copy your rocket and paste it in the same place where your rocket is, then name it "Bomb". Change it into a ball. Make its size 2, 2, 2 (or something else if preferred). Change any of the other properties, such as colour, however you want. Also, make sure CanCollide is off.
Second, you must set up the script for the bomb. Remove the function fly from the script so it reads:
r = game:service("RunService") shaft = script.Parent position = shaft.Position function blow() swoosh:stop() explosion = Instance.new("Explosion") explosion.Position = shaft.Position explosion.BlastRadius = 10 -- find instigator tag local creator = script.Parent:findFirstChild("creator") if creator ~= nil then explosion.Hit:connect(function(part, distance) onPlayerBlownUp(part, distance, creator) end) end explosion.Parent = game.Workspace connection:disconnect() wait(.1) shaft:remove() end function onTouch(hit) if hit.Name == "Building" or hit.Name == "Safe" then swoosh:stop() shaft:remove() return end local parent = hit.Parent.Parent local owner = shaft.Owner if owner ~= nil then if parent ~= nil and owner.Value ~= nil then if parent ~= owner.Value then local stunt = parent:FindFirstChild("Stunt") if stunt ~= nil then if stunt.Value ~= 1 then blow() end else blow() end end end end end function onPlayerBlownUp(part, distance, creator) if part.Name == "Head" then local humanoid = part.Parent:findFirstChild("Humanoid") tagHumanoid(humanoid, creator) end end function tagHumanoid(humanoid, creator) if creator ~= nil then local new_tag = creator:clone() new_tag.Parent = humanoid end end function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end t, s = r.Stepped:wait() swoosh = script.Parent.Swoosh swoosh:play() d = t + 4.0 - s connection = shaft.Touched:connect(onTouch) while t < d do t = r.Stepped:wait() end -- at max range script.Parent.Explosion.PlayOnRemove = false swoosh:stop() shaft:remove()
Also, change the line explosion.BlastRadius = 10 and put a different number for a different explosion radius.
Then you must modify the plane script.
Find your planeflyer script.
Paste the following under the function fire:
function bomb(pln,spn) local missile = bin.Bomb:clone() missile.CFrame = spn.CFrame * CFrame.new(0, -15, 0) missile.RocketScript.Disabled = false missile.Parent = game.Workspace local creator_tag = Instance.new("ObjectValue") creator_tag.Value = game.Players.LocalPlayer creator_tag.Name = "creator" creator_tag.Parent = missile missile.Owner.Value = pln end
Change bin.Bomb:clone() to script.Bomb:clone() if your bomb is a child of the planeflyer script.
Find the part of the script for the keyboard presses.
Under the key == "f" (in the space between the key == "f" and key == "x") part paste the following
if (key=="b") and (bin.Reload.Value == 0) then bomb(vehicle,plane.Engine) bin.Reload.Value = 1 wait(3) bin.Reload.Value = 0 end
If you want, change wait(3) to another number if you want to change the reload time for the bomb.
Shot Formations
Let's say you have just one gun on the front of your plane but instead of just firing a single shot you want it to shoot a formation of shots.:
First, look at the fire function and change it to look like this.
Change bin.Rocket:clone() to script.Rocket:clone() if you moved the rocket inside the script.
After that, you need to modify the firing script section.
You need to change it so that there is just the plane.Gun1 (or plane.Tip if you want to use the tip as your gun)
You also need to specify the two values for the x offset and y offsets:
if (key=="f") and (bin.Reload.Value == 0) then fire(vehicle,plane.Gun1,0,0) bin.Reload.Value = 1 wait(1) bin.Reload.Value = 0 end
Next, just add as many copies of fire(vehicle,plane.Gun1,0,0) you want, each time changing the two zeroes into different numbers to offset each shot you want. For example, this makes a 3x3 square array of shots:
if (key=="f") and (bin.Reload.Value == 0) then fire(vehicle,plane.Gun1,0,0) fire(vehicle,plane.Gun1,0,-10) fire(vehicle,plane.Gun1,0,10) fire(vehicle,plane.Gun1,-10,0) fire(vehicle,plane.Gun1,-10,-10) fire(vehicle,plane.Gun1,-10,10) fire(vehicle,plane.Gun1,10,0) fire(vehicle,plane.Gun1,10,-10) fire(vehicle,plane.Gun1,10,10) bin.Reload.Value = 1 wait(1) bin.Reload.Value = 0 end
You can alter this to make any pattern you want.
Cloaking
You just need a few values and a script to cloak your plane.
First, take a working plane.
If there are any cylindrical objects or decals on your plane, it's recommended you remove them (for the cylinders you can replace them with blocks). Also make sure there are no surfaces with "hinge", "motor" or "steppingmotor".
Next, you need to insert three IntValues. Name them "Cloaked", "Energy", and "CloakPercent". Set Energy to whatever maximum energy storage you want.
Next insert a script, and name it "CloakScript"
Section two of the script makes the plane transition from invisible to visible, and vice versa. Change "5" to another number to make the transition faster or slower.
You can change the number "vehicle.Energy.Value = vehicle.Energy.Value - 1" in section three to make cloaking drain energy faster and in "vehicle.Energy.Value = vehicle.Energy.Value + 1" to make cloak energy recharge faster. Change "1000" to whatever you have as the plane's maximum energy.
The first part of section four makes you uncloak when you have no energy. The second part makes the plane uncloak when you die. The third part makes the plane uncloak if you jump out.
Section five makes the message for the energy bar at the bottom of the screen when you are in the plane. You can play with the numbers a bit if you want.
The first three lines of section six make the plane's bodykit transparency equal the cloak percent. The rest of the lines identify each of the parts of the plane and the parts of the humanoid pilot. "gun1 = parts:FindFirstChild("Gun1")" can be copied additional times for each additional gun, if there are more than two.
Section seven controls the appearance of the face and shirt when cloaking and uncloaking. You don't need to edit it.
Section eight makes the parts of the plane and pilot become invisible or visible. Again, copy the line for the gun additional times if you have more than two guns.
Section nine is the end of the script, and the wait(0.1) makes the script run every 0.1 seconds (changing it will make everything faster or slower).
Here is the full default script. You can copy-paste this in your script and change the numbers and you are finished.
Now, you have a plane which can cloak, but you can't control the cloaking!
Open your plane tool, and select your PlaneFlyer script (if you have multiple planeflyer scripts for different planes, select the script for the plane you are making a cloaker)
Below this:
if (key=="t") and planedebounce == false and stuntdebounce == false then planedebounce = true stuntdebounce = true plane.Parent.Stunt.Value = 1 local body = plane.Engine.BodyGyro body.maxTorque = Vector3.new(9000, 9000, 9000) local currentframe = plane.Engine.CFrame local valy = 30 local valz = 30 for i = 1,8 do body.cframe = currentframe * CFrame.fromEulerAnglesXYZ(0, valy, valz) valy = valy +50 valz = valz +100 wait(.1) end body.cframe = currentframe * CFrame.fromEulerAnglesXYZ(0, 600, 0) wait(.5) body.maxTorque = Vector3.new(0, 0, 0) planedebounce = false plane.Parent.Stunt.Value = 0 wait(4) stuntdebounce = false end
you should add this little section of script:
if (key=="c") and planedebounce == false then if(vehicle.Cloaked.Value == 0) then vehicle.Cloaked.Value = 1 else vehicle.Cloaked.Value = 0 end end
This will make your plane cloak and uncloak when you press C.
Boosting
It is possible to make your plane "boost".
First you must add objects to the engine. First add two intvalues, and name one of them "Boosters" and the other "Fuel". Next add a script and name it "BoosterScript". Set the value of "Fuel" to however much fuel you want (i.e., with the default script for boosting below, 100 fuel lasts 10 seconds). Next you need to make the boost script.
Section one simply identifies stuff and creates the fuel message.
Section two makes the plane use up fuel while it is boosting.
Section three makes boosting stop when there is no fuel.
Section four is when you shut off the engines, the boosting shuts off too.
Section five makes the boosters stop when the plane is destroyed (and the pilot gets bloxxed), or when the pilot jumps out of the plane.
Section six makes a bar appear at the bottom of the pilot's screen so he can see how much fuel he has.
Section seven is this last part.
The whole script looks like this:
-- section one playerinplane = false engine = script.Parent parts = engine.Parent vehicle = parts.Parent message = Instance.new("Hint") while true do player = vehicle.Parent human = player:FindFirstChild("Humanoid") power = engine:FindFirstChild("FlyScript") -- section two if (engine.Boosters.Value == 1) then engine.Fuel.Value = engine.Fuel.Value - 1 end -- section three if (engine.Boosters.Value == 1) and (engine.Fuel.Value <= 0) then engine.Boosters.Value = 0 end -- section four if (engine.Boosters.Value == 1) and (power == nil) then engine.Boosters.Value = 0 end -- section five if (human ~= nil) then if (engine.Boosters.Value == 1) and (human.health <= 0) then engine.Boosters.Value = 0 message:Remove() end local weld = parts:FindFirstChild("Seat"):FindFirstChild("SeatWeld") if (weld == nil) or (weld.Part1 ~= player:FindFirstChild("Torso")) then engine.Boosters.Value = 0 message:Remove() end end -- section six if (engine.Fuel.Value >= 98) then message.Text = "Booster Fuel: (||||||||||||||||||||)" elseif (engine.Fuel.Value >= 93) and (engine.Fuel.Value < 98) then message.Text = "Booster Fuel: (||||||||||||||||||| )" elseif (engine.Fuel.Value >= 88) and (engine.Fuel.Value < 93) then message.Text = "Booster Fuel: (|||||||||||||||||| )" elseif (engine.Fuel.Value >= 83) and (engine.Fuel.Value < 88) then message.Text = "Booster Fuel: (||||||||||||||||| )" elseif (engine.Fuel.Value >= 78) and (engine.Fuel.Value < 83) then message.Text = "Booster Fuel: (|||||||||||||||| )" elseif (engine.Fuel.Value >= 73) and (engine.Fuel.Value < 78) then message.Text = "Booster Fuel: (||||||||||||||| )" elseif (engine.Fuel.Value >= 68) and (engine.Fuel.Value < 73) then message.Text = "Booster Fuel: (|||||||||||||| )" elseif (engine.Fuel.Value >= 63) and (engine.Fuel.Value < 68) then message.Text = "Booster Fuel: (||||||||||||| )" elseif (engine.Fuel.Value >= 58) and (engine.Fuel.Value < 63) then message.Text = "Booster Fuel: (|||||||||||| )" elseif (engine.Fuel.Value >= 53) and (engine.Fuel.Value < 58) then message.Text = "Booster Fuel: (||||||||||| )" elseif (engine.Fuel.Value >= 48) and (engine.Fuel.Value < 53) then message.Text = "Booster Fuel: (|||||||||| )" elseif (engine.Fuel.Value >= 43) and (engine.Fuel.Value < 48) then message.Text = "Booster Fuel: (||||||||| )" elseif (engine.Fuel.Value >= 38) and (engine.Fuel.Value < 43) then message.Text = "Booster Fuel: (|||||||| )" elseif (engine.Fuel.Value >= 33) and (engine.Fuel.Value < 38) then message.Text = "Booster Fuel: (||||||| )" elseif (engine.Fuel.Value >= 28) and (engine.Fuel.Value < 33) then message.Text = "Booster Fuel: (|||||| )" elseif (engine.Fuel.Value >= 23) and (engine.Fuel.Value < 28) then message.Text = "Booster Fuel: (||||| )" elseif (engine.Fuel.Value >= 18) and (engine.Fuel.Value < 23) then message.Text = "Booster Fuel: (|||| )" elseif (engine.Fuel.Value >= 13) and (engine.Fuel.Value < 18) then message.Text = "Booster Fuel: (||| )" elseif (engine.Fuel.Value >= 8) and (engine.Fuel.Value < 13) then message.Text = "Booster Fuel: (|| )" elseif (engine.Fuel.Value >= 3) and (engine.Fuel.Value < 8) then message.Text = "Booster Fuel: (| )" elseif (engine.Fuel.Value < 3) then message.Text = "Booster Fuel: ( )" end --section seven if (player.Name ~= "Station1") then if (playerinplane == false) then message.Parent = game.Players:FindFirstChild(player.Name) playerinplane = true end end wait(0.1) end
Next, open your plane tool and find the planeflyer script for the plane you want to have boost. Unhide this script's children, and find the FlyScript. Open the script:
Paste this in
local engine = script.Parent.Parent.Engine local spd = 5 local position = engine.Position while true do spd = 5 * ((script.Parent.Boosters.Value * 1) + 1) wait(.1) direction = engine.CFrame.lookVector position = position + spd*3*direction error = position - engine.Position engine.Velocity = spd*error engine.RotVelocity = Vector3.new(0, 0, 0) end
First, find "spd = 5". Change 5 to whatever speed you want your plane to have normally (3 is the default on most planes). Next, find the "((script.Parent.Boosters.Value * 1) + 1)". This part makes speed double when the boosters are activated. You can change the first 1 to another number to change the factor to increase the speed by (for example, 0.5 makes speed increase by 50%, while 2 makes the speed triple instead of double).
Open the PlaneFlyer script for the plane you are making boosters for.
Below the "if (key=="t")" section, or whatever is the last section for keypresses, paste the following (if you pasted it in the right place, the word "end" should appear in the script two times after the part you just pasted.
if (key=="b") and planedebounce == false then if (engine.Boosters.Value == 0) and (engine.Fuel.Value > 0) then engine.Boosters.Value = 1 else engine.Boosters.Value = 0 end end
If b is already taken by another action in your plane, change the letter b to another letter.
If you did everything right, you should be able to test your plane now and watch it boost!
Exhaust
If you want exhaust to come out of the plane when it boosts, paste this right before the "wait(0.1)" in the booster script
if (engine.Boosters.Value == 1) then exhaust = Instance.new("Part") exhaust.CFrame = engine.CFrame * CFrame.new(0, 0, 20) explosion = Instance.new("Explosion") explosion.Position = exhaust.Position explosion.BlastRadius = 1 exhaust:Remove() explosion.Parent = game.Workspace end
Landing Gear
You need some thing to have a landing gear. First you need a bool value in parts called Gear, make sure it is set true, also need the wheels. Call each piece Wheels#.
Let get to scripting... Insert this Below the "if (key=="t")" section...
if (key=="q") then local gear = plane.Gear if gear.Value == true then plane.Wheels#.CanCollide = false plane.Wheels#.Transparency = 1 gear.Value = false else plane.Wheels#.CanCollide = true plane.Wheels#.Transparency = 0 gear.Value = true end
copy the each part for the amount of wheels.
plane.Wheels#.CanCollide = false/true plane.Wheels#.Transparency = 0-1 gear.Value = false/true
Rockets Exaust
Add a new script into your rocket and call it Smoke. Insert the following inside.
LandMine = script.Parent while true do wait() explosion = Instance.new("Explosion") explosion.BlastRadius = 0.01 explosion.BlastPressure = 0.1 explosion.Position = script.Parent.Position explosion.Parent = game.Workspace script.Parent.Transparency = 0 end
Balefire Attack With Planes
Open your tool and then your plane flyer script and where you see
function fire(pln,spn) local missile = bin.Rocket:clone() missile.CFrame = spn.CFrame * CFrame.new(0, 0, -15) missile.RocketScript.Disabled = false missile.Parent = game.Workspace local creator_tag = Instance.new("ObjectValue") creator_tag.Value = game.Players.LocalPlayer creator_tag.Name = "creator" creator_tag.Parent = missile missile.Owner.Value = pln end
replace it with:
function fire(pln,engine) --local missile = bin.Rocket:clone() --missile.CFrame = spn.CFrame * CFrame.new(0, 0, -35) --missile.RocketScript.Disabled = false --missile.Parent = game.Workspace --local creator_tag = Instance.new("ObjectValue") --creator_tag.Value = game.Players.LocalPlayer --creator_tag.Name = "creator" --creator_tag.Parent = missile --missile.Owner.Value = pln dir = engine.CFrame.lookVector for i = 1, 50 do local ex = Instance.new("Explosion") ex.BlastRadius = 6 ex.BlastPressure = 8000000 ex.Position = engine.Position + (dir * 50) + (dir * i * 12) ex.Parent = game.Workspace end end
Homing Missiles
To make a homing missile, first, make a block for the missile. For the size, Z is the length of the missile, so you usually want this to be higher than X or Y. When you have made your missile, name it "HomingRocket". Cut out the rocket with ctrl+x, and then paste it in your plane tool where you have your normal rocket for your plane with ctrl+v. Open your normal rocket, and copy/paste all its children (Owner, RocketScript, and sounds) into the homing missile, then insert a RocketPropulsion object.
In the rocketpropulsion object, set CartoonFactor to 1 (you can set it to a different number if you want to, though). Also play with the thrust and turn. The missile I made has a maxspeed of 1000, a maxthrust of 10 000 000 (the size of my rocket is 2,2,8), a thrustD of 0.01, a thrustP of 100, a MaxTorque of 400000,400000,0, a TurnD of 500, and a turnP of 3000. You don't have to use these numbers, just put any numbers you think would be good for a plane-launched homing missile.
Open the rocketscript, and paste this:
r = game:service("RunService") shaft = script.Parent position = shaft.Position shaft.RocketPropulsion:Fire() function fly() direction = shaft.CFrame.lookVector position = position + 35*direction error = position - shaft.Position shaft.Velocity = 5*error end function blow() swoosh:stop() explosion = Instance.new("Explosion") explosion.Position = shaft.Position explosion.BlastRadius = 20 -- find instigator tag local creator = script.Parent:findFirstChild("creator") if creator ~= nil then explosion.Hit:connect(function(part, distance) onPlayerBlownUp(part, distance, creator) end) end explosion.Parent = game.Workspace connection:disconnect() wait(.1) shaft:remove() end function onTouch(hit) print("Target Hit") if hit.Name == "Building" or hit.Name == "Safe" then swoosh:stop() shaft:remove() return end local parent = hit.Parent.Parent local owner = shaft.Owner if owner ~= nil then if parent ~= nil and owner.Value ~= nil then if parent ~= owner.Value then local stunt = parent:FindFirstChild("Stunt") if stunt ~= nil then if stunt.Value ~= 1 then blow() end else blow() end end end end end function onPlayerBlownUp(part, distance, creator) if part.Name == "Head" then local humanoid = part.Parent:findFirstChild("Humanoid") tagHumanoid(humanoid, creator) end end function tagHumanoid(humanoid, creator) if creator ~= nil then local new_tag = creator:clone() new_tag.Parent = humanoid end end function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end t, s = r.Stepped:wait() swoosh = script.Parent.Swoosh swoosh:play() d = t + 10 - s connection = shaft.Touched:connect(onTouch) while t < d do t = r.Stepped:wait() end -- at max range swoosh:stop() script.Parent.RocketPropulsion:Abort()
Change the blastradius if you want, or the number in d = t + 10 - s to change the missile's range.
Open the plane tool, under the part that assigns objects to variables (bin = script.Plane, etc.), paste local homingtarget = nil
Add the following below function fire (not in the function itself, under the entire function)
function firehomingmissile(pln,spn) local missile = bin.HomingRocket:clone() missile.CFrame = spn.CFrame * CFrame.new(0, 0, -35) missile.RocketPropulsion.Target = homingtarget missile.RocketScript.Disabled = false missile.Parent = game.Workspace local creator_tag = Instance.new("ObjectValue") creator_tag.Value = game.Players.LocalPlayer creator_tag.Name = "creator" creator_tag.Parent = missile missile.Owner.Value = pln end
If the missile is in the script, change bin.HomingRocket:clone() to script.HomingRocket:clone(). If the missile is directly in the tool, leave it as-is.
At the top of function onButton1Down, add homingtarget = mouse.Target. This will make the tool set the object clicked on as the target for firing a homing missile.
Find the firing function if (key=="f") then ... end of the plane tool. Below it, paste this (this makes the homing missile fire when you press a key).
Change the key if you want to. Also, find plane.MissileLauncher1 and change that to any part of your plane where the front of that object is facing forward (for example, plane.Engine).
Change the time on the wait line if you want to change the cooldown time of your weapons after the missile is fired.
Test your place, get into the plane, click something in your place, and press the key you set up for firing the missile. A missile should come out of your plane and turn to face the object, then go to it and explode when it reaches the object.
Bullets
Copy your rocket and name it Bullet. On the RocketScript make sure to delete the blow function so it does not explode as a rocket.
Insert a new script in the bullet and name it BulletScript then insert this script.
Open your PlaneFlyer script and insert this script under the fire function.
Look on the onKeyDown function for the fire key and insert this script under that.
Speed
To start replace the flyscript with this
local engine = script.Parent.Parent.Engine local position = engine.Position while true do wait(.1) spd = script.Parent.Speed.Value direction = engine.CFrame.lookVector position = position + spd*3*direction error = position - engine.Position engine.Velocity = spd*error engine.RotVelocity = Vector3.new(0, 0, 0) end
on the tool insert a intValue and call it speed. On the planeflyer add creativeval = 1 on the very top then go to onKeyDown function and replace the key x and the key y with the following
if (key=="x") and planedebounce == false then local power = plane.Engine:findFirstChild("FlyScript") if (power ~= nil) then power:remove() end local spd = plane.Engine:findFirstChild("Speed") if (spd ~= nil) then spd:remove() end end if (key=="y") then local power = plane.Engine:findFirstChild("FlyScript") if (power ~= nil) then return end local fly = script.FlyScript:clone() fly.Disabled = false fly.Parent = plane.Engine local spd = plane.Engine:findFirstChild("Speed") if (spd ~= nil) then return end local speed = script.Parent.Speed:clone() speed.Parent = plane.Engine end
Add this part to make the speed to change
if (key=="n") and planedebounce == false then local val = plane.Engine:findFirstChild("Speed") if (val == nil) or (val.Value == creativeval) then return end plane.Engine.Speed.Value = val.Value - 1 end if (key=="m") and planedebounce == false then local val = plane.Engine:findFirstChild("Speed") if (val == nil) then return end plane.Engine.Speed.Value = val.Value + 1 end
Warning: Do not use boosters or plane will not work because both edit differently the flyscript
Sequential Firing
This is actually very simple to do. First, make four bricks and name them Gun1, Gun2, Gun3, and Gun4. Put Gun1 and Gun2 on the left part of your plane. Put the other two on the right side of your plane and drag them into the Parts model of your plane. Also make sure the front surface of the bricks is facing where you want to fire. Insert a boolvalue and name it mode, what its set doesn't really matter. Next, open up your planeflyer script inside your plane tool and replace the contents of the firing script section with this script. Now your plane should fire one wing's guns, then the other each time you press "f".
Tool Giver Plane
If you want to make that when you are seated you get tool and if not you don't have it well first put the tool in the Lightning service then on Parts look for script and open it. Then replace it with this script
Team Coloring Plane
If you want to make the plane colors on the team color then add a Brick Color Value to the plane and name it PlaneColor. In bodykit name all the parts you want to color ColorMe and then replace the script the plane itself with this script.