Advertisement
Mattsmith1579

Flight tool

Sep 19th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. local power = 20
  2. wait(2)
  3. local bin = script.Parent
  4. local fly = false
  5. local origval = bin.Origin.Value
  6. local value = origval.Inside
  7. local entry = origval.Entry
  8. local base = entry.Base
  9. local airborne = false
  10.  
  11. local intsounds = value.Parts.Console.CenterThing
  12. introtor = intsounds.Rotor
  13. extrotor = base.Rotor
  14.  
  15.  
  16.  
  17.  
  18. function onButton1Down(mouse)
  19. if (value.Flying.Value) then
  20. ----
  21. if base:findFirstChild("Spin") then
  22. local fba = base:findFirstChild("Spin")
  23. end
  24. if base:findFirstChild("FlightPos") then
  25. local bpos = base:findFirstChild("FlightPos")
  26. end
  27. if base:findFirstChild("FlightGyro") then
  28. local gyro = base:findFirstChild("FlightGyro")
  29. end
  30. fly = true
  31. while (fly) and (value.Flying.Value) do
  32. local power = value.MovSpeed.Value
  33. ----
  34. if (power >= 1) then
  35. fba.angularvelocity = Vector3.new(0,1,0)
  36. end
  37. if (power == 0) then
  38. fba.angularvelocity = Vector3.new(0,0,0)
  39. end
  40. if (power >= 20) then
  41. fba.angularvelocity = Vector3.new(0,2,0)
  42. end
  43. if (power >= 40) then
  44. fba.angularvelocity = Vector3.new(0,3,0)
  45. end
  46. if (power >= 50) then
  47. fba.angularvelocity = Vector3.new(0,4,0)
  48. end
  49. if (power >= 100) then
  50. fba.angularvelocity = Vector3.new(0,5,0)
  51. end
  52. if (value.EntryFreak.Value) then
  53. gyro.maxTorque = Vector3.new(0,0,0)
  54. fba.angularvelocity = Vector3.new(math.random(0,5),math.random(0,5),math.random(0,5))
  55. else
  56. gyro.maxTorque = Vector3.new(200,0,200)
  57. end
  58. ----
  59. pos = mouse.Hit.p
  60. bpos.position = base.Position + (pos-base.Position).unit * power
  61. wait()
  62. end
  63. fly = false
  64. end
  65. end
  66.  
  67. function onMove(mouse)
  68. pos = mouse.Hit.p
  69. end
  70.  
  71. function onButton1Up(mouse)
  72. fly = false
  73. end
  74.  
  75. function onSelected(mouse)
  76. print("select")
  77. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  78. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  79. mouse.Move:connect(function() onMove(mouse) end)
  80. mouse.KeyDown:connect(onKeyDown)
  81. end
  82.  
  83. --[[function onDeselected(mouse)
  84. print("deselect")
  85.  
  86. end--]]
  87.  
  88. --[[value.Flying.Changed:connect(function()
  89. if airborne == true then
  90. airborne = false
  91. bpos:Remove()
  92. end
  93. end)
  94. --]]
  95.  
  96. function startflight()
  97. if (value.Working.Value) or (value.Timing.Value) or (value.Fused.Value) or (value.Fule.Value == 0) then return end
  98. value.Flying.Value = true
  99. introtor:play()
  100. extrotor:play()
  101. fba = Instance.new("BodyAngularVelocity")
  102. fba.Name = "Spin"
  103. fba.Parent = base
  104. fba.angularvelocity = Vector3.new(0,1,0)
  105. fba.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  106. ----
  107. bpos = Instance.new("BodyPosition")
  108. bpos.maxForce = Vector3.new(math.huge,math.huge,math.huge)
  109. bpos.Parent = base
  110. bpos.position = base.Position
  111. bpos.Name = "FlightPos"
  112. --
  113. gyro = Instance.new("BodyGyro")
  114. gyro.maxTorque = Vector3.new(200,0,200)
  115. gyro.D = 0
  116. gyro.P = 200
  117. gyro.Parent = base
  118. gyro.Name = "FlightGyro"
  119. --
  120. end
  121.  
  122.  
  123. function endflight()
  124. value.Flying.Value = false
  125. introtor:stop()
  126. extrotor:stop()
  127. --
  128. for i=1,3 do
  129. wait(0.000001)
  130. if base:findFirstChild("Spin") then
  131. base:findFirstChild("Spin"):Remove()
  132. end
  133. if base:findFirstChild("FlightPos") then
  134. base:findFirstChild("FlightPos"):Remove()
  135. end
  136. if base:findFirstChild("FlightGyro") then
  137. base:findFirstChild("FlightGyro"):Remove()
  138. end
  139. end
  140. end
  141.  
  142. function onKeyDown(key)
  143. if key == "z" then
  144. if (value.Flying.Value) then
  145. endflight()
  146. else
  147. startflight()
  148. end
  149. end
  150. if key == "q" then
  151. if (value.MovSpeed.Value > 0) then
  152. value.MovSpeed.Value = value.SpeedButton.Value - 1
  153. end
  154. end
  155. if key == "e" then
  156. if (value.MovSpeed.Value < 50) then
  157. value.MovSpeed.Value = value.SpeedButton.Value + 1
  158. end
  159. end
  160. end
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. bin.Selected:connect(onSelected)
  168. bin.Deselected:Connect(onDeselected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement