Charliezkie

Roblox Fly Script

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