Advertisement
loleriss

Untitled

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