Advertisement
Imperious123

Untitled

Jul 26th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. getgenv().flying = true
  2. getgenv().speed = 2
  3. local function FLY()
  4. local T = game:service("Players").LocalPlayer.Character.HumanoidRootPart
  5. local iyflyspeed = getgenv().speed
  6. local IYMouse = game:service("Players").LocalPlayer:GetMouse()
  7. local CONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
  8. local lCONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
  9. local SPEED = 0
  10. local fly = getgenv().flying
  11. local BG = Instance.new('BodyGyro', T)
  12. local BV = Instance.new('BodyVelocity', T)
  13. BG.P = 9e4
  14. BG.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  15. BG.cframe = T.CFrame
  16. BV.velocity = Vector3.new(0, 0, 0)
  17. BV.maxForce = Vector3.new(9e9, 9e9, 9e9)
  18. spawn(function()
  19. repeat wait()
  20. if CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0 or CONTROL.Q + CONTROL.E ~= 0 then
  21. SPEED = 50
  22. elseif not (CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0 or CONTROL.Q + CONTROL.E ~= 0) and SPEED ~= 0 then
  23. SPEED = 0
  24. end
  25. if (CONTROL.L + CONTROL.R) ~= 0 or (CONTROL.F + CONTROL.B) ~= 0 or (CONTROL.Q + CONTROL.E) ~= 0 then
  26. BV.velocity = ((workspace.CurrentCamera.CoordinateFrame.lookVector * (CONTROL.F + CONTROL.B)) + ((workspace.CurrentCamera.CoordinateFrame * CFrame.new(CONTROL.L + CONTROL.R, (CONTROL.F + CONTROL.B + CONTROL.Q + CONTROL.E) * 0.2, 0).p) - workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
  27. lCONTROL = {F = CONTROL.F, B = CONTROL.B, L = CONTROL.L, R = CONTROL.R}
  28. elseif (CONTROL.L + CONTROL.R) == 0 and (CONTROL.F + CONTROL.B) == 0 and (CONTROL.Q + CONTROL.E) == 0 and SPEED ~= 0 then
  29. BV.velocity = ((workspace.CurrentCamera.CoordinateFrame.lookVector * (lCONTROL.F + lCONTROL.B)) + ((workspace.CurrentCamera.CoordinateFrame * CFrame.new(lCONTROL.L + lCONTROL.R, (lCONTROL.F + lCONTROL.B + CONTROL.Q + CONTROL.E) * 0.2, 0).p) - workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
  30. else
  31. BV.velocity = Vector3.new(0, 0, 0)
  32. end
  33. BG.cframe = workspace.CurrentCamera.CoordinateFrame
  34. until not getgenv().flying
  35. CONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
  36. lCONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
  37. SPEED = 0
  38. BG:destroy()
  39. BV:destroy()
  40. end)
  41. IYMouse.KeyDown:connect(function(KEY)
  42. if KEY:lower() == 'w' then
  43. if vfly then
  44. CONTROL.F = vehicleflyspeed
  45. else
  46. CONTROL.F = iyflyspeed
  47. end
  48. elseif KEY:lower() == 's' then
  49. if vfly then
  50. CONTROL.B = - vehicleflyspeed
  51. else
  52. CONTROL.B = - iyflyspeed
  53. end
  54. elseif KEY:lower() == 'a' then
  55. if vfly then
  56. CONTROL.L = - vehicleflyspeed
  57. else
  58. CONTROL.L = - iyflyspeed
  59. end
  60. elseif KEY:lower() == 'd' then
  61. if vfly then
  62. CONTROL.R = vehicleflyspeed
  63. else
  64. CONTROL.R = iyflyspeed
  65. end
  66. elseif KEY:lower() == 'e' then
  67. if vfly then
  68. CONTROL.Q = vehicleflyspeed*2
  69. else
  70. CONTROL.Q = iyflyspeed*2
  71. end
  72. elseif KEY:lower() == 'q' then
  73. if vfly then
  74. CONTROL.E = -vehicleflyspeed*2
  75. else
  76. CONTROL.E = -iyflyspeed*2
  77. end
  78. end
  79. end)
  80. IYMouse.KeyUp:connect(function(KEY)
  81. if KEY:lower() == 'w' then
  82. CONTROL.F = 0
  83. elseif KEY:lower() == 's' then
  84. CONTROL.B = 0
  85. elseif KEY:lower() == 'a' then
  86. CONTROL.L = 0
  87. elseif KEY:lower() == 'd' then
  88. CONTROL.R = 0
  89. elseif KEY:lower() == 'e' then
  90. CONTROL.Q = 0
  91. elseif KEY:lower() == 'q' then
  92. CONTROL.E = 0
  93. end
  94. end)
  95. end
  96. FLY()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement