Advertisement
FazeWolfyBoy

Fly

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