Advertisement
UnoPastes

FlyingScript

Feb 28th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.11 KB | None | 0 0
  1. local mouse = game.Players.LocalPlayer:GetMouse()
  2. repeat wait() until mouse
  3. local plr = game.Players.LocalPlayer
  4. local torso = plr.Character.Torso
  5. local flying = true
  6. local deb = true
  7. local ctrl = {f = 0, b = 0, l = 0, r = 0}
  8. local lastctrl = {f = 0, b = 0, l = 0, r = 0}
  9. local maxspeed = 200
  10. local speed = 75
  11.  
  12. function Fly()
  13. local bg = Instance.new("BodyGyro", torso)
  14. bg.P = 9e4
  15. bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  16. bg.cframe = torso.CFrame
  17. local bv = Instance.new("BodyVelocity", torso)
  18. bv.velocity = Vector3.new(0,0.1,0)
  19. bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
  20. repeat wait()
  21. plr.Character.Humanoid.PlatformStand = true
  22. if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 then
  23. speed = speed+.5+(speed/maxspeed)
  24. if speed > maxspeed then
  25. speed = maxspeed
  26. end
  27. elseif not (ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0) and speed ~= 0 then
  28. speed = speed-1
  29. if speed < 0 then
  30. speed = 0
  31. end
  32. end
  33. if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then
  34. bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed
  35. lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}
  36. elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 then
  37. bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed
  38. else
  39. bv.velocity = Vector3.new(0,0.1,0)
  40. end
  41. bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*50*speed/maxspeed),0,0)
  42. until not flying
  43. ctrl = {f = 0, b = 0, l = 0, r = 0}
  44. lastctrl = {f = 0, b = 0, l = 0, r = 0}
  45. speed = 0
  46. bg:Destroy()
  47. bv:Destroy()
  48. plr.Character.Humanoid.PlatformStand = false
  49. end
  50. mouse.KeyDown:connect(function(key)
  51. if key:lower() == "f" then
  52. if flying then flying = false
  53. else
  54. flying = true
  55. Fly()
  56. end
  57. elseif key:lower() == "w" then
  58. ctrl.f = 1
  59. elseif key:lower() == "s" then
  60. ctrl.b = -1
  61. elseif key:lower() == "a" then
  62. ctrl.l = -1
  63. elseif key:lower() == "d" then
  64. ctrl.r = 1
  65. end
  66. end)
  67. mouse.KeyUp:connect(function(key)
  68. if key:lower() == "w" then
  69. ctrl.f = 0
  70. elseif key:lower() == "s" then
  71. ctrl.b = 0
  72. elseif key:lower() == "a" then
  73. ctrl.l = 0
  74. elseif key:lower() == "d" then
  75. ctrl.r = 0
  76. end
  77. end)
  78. local mouse = game.Players.LocalPlayer:GetMouse()
  79. repeat wait() until mouse
  80. local plr = game.Players.LocalPlayer
  81. local torso = plr.Character.Torso
  82. local flying = true
  83. local deb = true
  84. local ctrl = {f = 0, b = 0, l = 0, r = 0}
  85. local lastctrl = {f = 0, b = 0, l = 0, r = 0}
  86. local maxspeed2 = 50
  87. local speed2 = 0
  88.  
  89. function Fly2()
  90. local bg = Instance.new("BodyGyro", torso)
  91. bg.P = 9e4
  92. bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  93. bg.cframe = torso.CFrame
  94. local bv = Instance.new("BodyVelocity", torso)
  95. bv.velocity = Vector3.new(0,0.1,0)
  96. bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
  97. repeat wait()
  98. plr.Character.Humanoid.PlatformStand = true
  99. if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 then
  100. speed2 = speed2+.5+(speed2/maxspeed2)
  101. if speed2 > maxspeed2 then
  102. speed2 = maxspeed2
  103. end
  104. elseif not (ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0) and speed ~= 0 then
  105. speed2 = speed2-1
  106. if speed2 < 0 then
  107. speed2 = 0
  108. end
  109. end
  110. if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then
  111. bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed2
  112. lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}
  113. elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed2 ~= 0 then
  114. bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed2
  115. else
  116. bv.velocity = Vector3.new(0,0.1,0)
  117. end
  118. bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*50*speed2/maxspeed2),0,0)
  119. until not flying2
  120. ctrl = {f = 0, b = 0, l = 0, r = 0}
  121. lastctrl = {f = 0, b = 0, l = 0, r = 0}
  122. speed = 0
  123. bg:Destroy()
  124. bv:Destroy()
  125. plr.Character.Humanoid.PlatformStand = false
  126. end
  127. mouse.KeyDown:connect(function(key)
  128. if key:lower() == "g" then
  129. if flying2 then flying2 = false
  130. else
  131. flying2 = true
  132. Fly2()
  133. end
  134. elseif key:lower() == "w" then
  135. ctrl.f = 1
  136. elseif key:lower() == "s" then
  137. ctrl.b = -1
  138. elseif key:lower() == "a" then
  139. ctrl.l = -1
  140. elseif key:lower() == "d" then
  141. ctrl.r = 1
  142. end
  143. end)
  144. mouse.KeyUp:connect(function(key)
  145. if key:lower() == "w" then
  146. ctrl.f = 0
  147. elseif key:lower() == "s" then
  148. ctrl.b = 0
  149. elseif key:lower() == "a" then
  150. ctrl.l = 0
  151. elseif key:lower() == "d" then
  152. ctrl.r = 0
  153. end
  154. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement