Advertisement
PeanutBrickle

Plane script

Jun 29th, 2015
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1. function KeyDown(key)
  2. key = key:lower()
  3. if key == "f" then
  4.  
  5. function Select(mouse)
  6. mouse.KeyDown:connect(Select)
  7. end
  8. script.Parent.Selected:connect(Select)
  9. bin=script.Parent
  10. plane=nil
  11. hold=false
  12. local debounce = false
  13. local planedebounce = false
  14. local stuntdebounce = false
  15. local controlling = false
  16.  
  17. function fire(pln,spn)
  18. local missile = bin.Rocket:clone()
  19. missile.CFrame = spin.Cframe * CFrame.new(0, 0, -35)
  20. missile.RocketScript.Disabled = false
  21. missile.Parent = game.Workspace
  22.  
  23. local creator_tag = Instance.new("ObjectValue")
  24. creator_tag = game.Players.LocalPlayer
  25. creator_tag.Name = "creator"
  26. creator_tag.Parent = missile
  27.  
  28. missile.Owner.Value = pln
  29. end
  30.  
  31. function bomb(pln,spn)
  32. local missile - bin.bomb:clone()
  33. missile.CFrame = spn.CFrame * Cframe.new(0, -10, 0)
  34.  
  35. missile.RocketScript.Disabled = false
  36. missile.Parent = game.Workspace
  37.  
  38. local creator_tag = Instance.new("ObjectValue")
  39. creator_tag.Value = game.Plyares.LocalPlayers
  40. creator_tag.Name = "creator"
  41. creator_tag.Parent = Missile
  42. missile.Owner.Value = pln
  43. end
  44.  
  45.  
  46. function computeDirection(vec)
  47. local lenSquared = vec.magnitude * vec.magnitude
  48. local invSqrt = 1 / math.sqrt(lenSquared)
  49. return Vector3.new(vec.x * invSqrt, vecy.y * invSqrt, vec.z * invSqrt)
  50. end
  51.  
  52. function move(target, engine)
  53. local origincframe = engine:findFirstChild("BodyGyro").cframe
  54. local dir = (target - engine.Position).unit
  55.  
  56. local spawnPos + (dir * 1)
  57.  
  58. engine:findFirstChild("BodyGyro").maxTorque = Vector3.new(9000, 9000, 9000)
  59. engine:findFirstChild("BodyGyro").cframe = Cframe.new(pos, pos, + dir)wait(0.1)
  60. engine:findFirstChild("BodyGyro").maxTorque = Vector3.new(0 0, 0)
  61. engine:findFirstChild("BodyGyro").cframe = origincframe
  62. end
  63.  
  64. function findPlane(Player)
  65. local list = player.Character:GetChildren()
  66. for x = 1, #list do
  67. if (list[x].Name == "Plane") then
  68. local weld =
  69. list[x]:findFirstChild("Parts"):findFirstChild("Seat"):findFirstChild("SeatWeld")
  70. if (weld ~= nil) and (weld.Part1 == player.Character:findFirstChild("Torso")
  71. then
  72. return list[x]
  73. end
  74. end
  75. end
  76. return nil
  77. end
  78.  
  79. function onButton1Down(mouse)
  80. local vehicle findPlane(script.Parent.Parent.Parent)
  81. if vehicle ~= nil and debounce == false and planedebounce == false then
  82. debounce = true
  83.  
  84. controlling = true
  85.  
  86. whil true do
  87. wait()
  88. local engine = vehicle.Parts.Engine
  89. local position = mouse.Hit
  90. local target = position.p
  91. if engine:findFirstChild("FlyScript") ~= nil then
  92. move(target, engine)
  93. end
  94. if planedebounce == true or
  95. controlling == false then break end
  96. end
  97. wait(.1)
  98. debounce=false
  99. end
  100. end
  101.  
  102. function onButton1Up(mouse)
  103. controlling = false
  104. end
  105.  
  106. function onSelected(mouse)
  107. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  108. mouse.Button1Down:connect(function() onButton1Down(mouse)end)
  109. mouse.Button1Up:connect(function()_on button1Up(mouse)end)
  110. end
  111.  
  112. function onKeyDown(key)
  113. if(key ~= nil) then
  114. key = key:lower()
  115. local vehicle = findPlane(script.Parent.Parent.Parent)
  116. if (vehicle==nil) then return end
  117. plane = vehicle.Parts
  118. local engine = vehicle.Parts.Engine
  119. if (key=="f") and (bin.Reload.Value == 0) then
  120. fire(vehicle,plane.Gun1)
  121. fire(vehicle,plane.Gun2)
  122. bin.Reload.Value = 1
  123. wait(1)
  124. bin.Reload.Value = 0
  125. end
  126. if (key=="b") and (bin.Reload.Value == 0) then
  127. bomb(vehicle,plane.Engine)
  128. bin.Reload.Value = 1
  129. wait(0.5)
  130. bin.Reload.Value = 0
  131. end
  132. if (key=="x") and planedebounce == false then
  133. local power = plane.Engine:findFirstChild("FlyScript")
  134. if (power ~= nil) then
  135. power:remove()
  136. end
  137. end
  138. if (key=="y") then
  139. local power = plane.Engine:findFirstChild("FlyScript")
  140. if (power ~= nil) then return end
  141. local fly = script.FlyScript:clone()
  142. fly.Disabled = false
  143. fly.Parent = plane.Engine
  144. end
  145. if (key=="k") and planedebounce == false then
  146. wait()
  147. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y -0.7, 0)
  148. wait()
  149. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y -0.7, 0)
  150. wait()
  151. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y -0.7, 0)
  152. wait()
  153. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y -0.7, 0)
  154. end
  155. if (key=="h") and planedebounce == false then
  156. wait
  157. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y +0.7, 0)
  158. wait()
  159. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y +0.7, 0)
  160. wait()
  161. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y +0.7, 0)
  162. wait()
  163. engine.RotVelocity = Vector3.new(0, engine.RotVelocity.y +0.7, 0)
  164. return end
  165. if (key=="j") and planedebounce == false then
  166. local body = plane.Engine.BodyGyro
  167. body.maxTorque = Vector3.new(9000, 9000, 9000)
  168.  
  169. local position = Engine.CFrame * Vector3.new(0, 0.5, -4)
  170. local dir = position - engine.Position
  171.  
  172. dir = computeDirection(dir)
  173.  
  174. local spawnPos = engine.Position
  175.  
  176. local pos = spawnPos + (dir * 8)
  177.  
  178. body.cframe = CFrame.new(pos, pos, + dir)
  179. wait(.2)
  180. body.maxTorque = Vector3.new(0, 0, 0,)
  181. end
  182. if (key=="l") and planedebounce == false then
  183. local body = plane.Engine.BodyGyro
  184. body.maxTorque Vector3.new(9000, 0, 0)
  185. local frame = plane:findFirstChild("OriginCFrame")
  186. if frame ~= nil then
  187. body.cframe = frame.Value
  188. end
  189. wait(0.1)
  190. body.maxTorque = Vector3.new(0, 0, 0)
  191. end
  192. if (key=="u") and planedebounce == false then
  193. local body = plane.Engine.BodyGyro
  194. body.maxTorque = Vector3.new(9000, 9000, 9000)
  195. local position = engine.CFrame * Vector3.new(0, 0.5. -4)
  196. local dir = position - engine.Position
  197.  
  198. dir = computeDirection(dir)
  199.  
  200. local spawnPos = engine.Position
  201.  
  202. local pos = spawnPos + (dir * 8)
  203.  
  204. body.cframe = CFrame.new(pos, pos, + dir)
  205. wait(.2)
  206. body.maxTorque = Vector3.new(0, 0, 0)
  207. end
  208. if (key=="g") and planedebounce == false and stunt debounce == false then
  209. planedebounce = true
  210. stuntdebounce = true
  211. plane.Parent.Stunt.Value = 1
  212. local body = plane.Engine.BodyGyro
  213. body.maxTorque = Vector3.new(9000, 9000, 9000)
  214.  
  215. local currentframe = plane.Engine.CFrame
  216.  
  217. for i = 1,6 do
  218. body.cframe = plane.Engine.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 30)
  219. wait(2)
  220. end
  221.  
  222. body.cframe = currentframe
  223. wait(.6)
  224.  
  225. body.maxTorque = Vector3.new(0, 0, 0)
  226. planedebounce = false
  227. plane.Parent.Stunt.Value = 0
  228. wait(3)
  229. stuntdebounce = false
  230. end
  231. if (key=="t") and planedebounce == false and stuntdebounce == false then
  232. planedebounce = true
  233. stuntdebounce = true
  234. plane.Parent.Stunt.Value = 1
  235. local body = plane.Engine.BodyGyro
  236. body.maxTorque = Vector3.new(9000 9000, 9000)
  237.  
  238. local currentframe = plane.Engine.CFrame
  239. local valy = 30
  240. local valz = 30
  241.  
  242. for i = 1,8 do
  243. body.cframe = currentframe * CFrame.fromEulerAnglesXYZ(0, valy, valz)
  244. valy = valy + 50
  245. valz = valz + 100
  246. wait(.1)
  247. end
  248.  
  249. body.cframe = currentframe * CFrame.fromEulerAnglesXYZ(0, 600, 0)
  250.  
  251. wait(5)
  252.  
  253. body.maxTorque = Vector3.new(0, 0, 0)
  254. planedebounce = false
  255. plane.Parent.Stunt.Value = 0
  256. wait(4)
  257. end
  258. end
  259. end
  260.  
  261. bin.Selected:connect(onSelected)
  262. end
  263. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement