Advertisement
gamie0412

Untitled

Jan 2nd, 2022
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. repeat wait()
  2. until game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:findFirstChild("Torso") and game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
  3. local mouse = game.Players.LocalPlayer:GetMouse()
  4. repeat wait() until mouse
  5. local plr = game.Players.LocalPlayer
  6. local torso = plr.Character.Torso
  7. local flying = true
  8. local deb = true
  9. local ctrl = {f = 0, b = 0, l = 0, r = 0}
  10. local lastctrl = {f = 0, b = 0, l = 0, r = 0}
  11. local maxspeed = 50
  12. local speed = 0
  13.  
  14. function Fly()
  15. local bg = Instance.new("BodyGyro", torso)
  16. bg.P = 9e4
  17. bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  18. bg.cframe = torso.CFrame
  19. local bv = Instance.new("BodyVelocity", torso)
  20. bv.velocity = Vector3.new(0,0.1,0)
  21. bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
  22. repeat wait()
  23. plr.Character.Humanoid.PlatformStand = true
  24. if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 then
  25. speed = speed+.5+(speed/maxspeed)
  26. if speed > maxspeed then
  27. speed = maxspeed
  28. end
  29. elseif not (ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0) and speed ~= 0 then
  30. speed = speed-1
  31. if speed < 0 then
  32. speed = 0
  33. end
  34. end
  35. if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then
  36. 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
  37. lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}
  38. elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 then
  39. 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
  40. else
  41. bv.velocity = Vector3.new(0,0.1,0)
  42. end
  43. bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*50*speed/maxspeed),0,0)
  44. until not flying
  45. ctrl = {f = 0, b = 0, l = 0, r = 0}
  46. lastctrl = {f = 0, b = 0, l = 0, r = 0}
  47. speed = 0
  48. bg:Destroy()
  49. bv:Destroy()
  50. plr.Character.Humanoid.PlatformStand = false
  51. end
  52. mouse.KeyDown:connect(function(key)
  53. if key:lower() == "e" then
  54. if flying then flying = false
  55. Button2.Text = "Press E to toggle flight! Status: Off"
  56. else
  57. flying = true
  58. Button2.Text = "Press E to toggle flight! Status: On"
  59. Fly()
  60. end
  61. elseif key:lower() == "w" then
  62. ctrl.f = 1
  63. elseif key:lower() == "s" then
  64. ctrl.b = -1
  65. elseif key:lower() == "a" then
  66. ctrl.l = -1
  67. elseif key:lower() == "d" then
  68. ctrl.r = 1
  69. end
  70. end)
  71. mouse.KeyUp:connect(function(key)
  72. if key:lower() == "w" then
  73. ctrl.f = 0
  74. elseif key:lower() == "s" then
  75. ctrl.b = 0
  76. elseif key:lower() == "a" then
  77. ctrl.l = 0
  78. elseif key:lower() == "d" then
  79. ctrl.r = 0
  80. end
  81. end)
  82. Fly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement