Advertisement
StenHisDirt

Fly

Nov 19th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. if Fly == false then
  2. Fly = true
  3. local mouse=game.Players.LocalPlayer:GetMouse''
  4. localplayer=game.Players.LocalPlayer
  5. game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
  6. local torso = game.Players.LocalPlayer.Character.HumanoidRootPart
  7. local speed=0
  8. local keys={a=false,d=false,w=false,s=false}
  9. local e1
  10. local e2
  11. local function start()
  12. local pos = Instance.new("BodyPosition",torso)
  13. local gyro = Instance.new("BodyGyro",torso)
  14. pos.Name="EPIXPOS"
  15. pos.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  16. pos.position = torso.Position
  17. gyro.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  18. gyro.cframe = torso.CFrame
  19. repeat
  20. wait()
  21. localplayer.Character.Humanoid.PlatformStand=true
  22. local new=gyro.cframe - gyro.cframe.p + pos.position
  23. if not keys.w and not keys.s and not keys.a and not keys.d then
  24. speed=1
  25. end
  26. if keys.w then
  27. new = new + workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  28. speed=speed+0.02
  29. end
  30. if keys.s then
  31. new = new - workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  32. speed=speed+0.02
  33. end
  34. if keys.d then
  35. new = new * CFrame.new(speed,0,0)
  36. speed=speed+0.02
  37. end
  38. if keys.a then
  39. new = new * CFrame.new(-speed,0,0)
  40. speed=speed+0.02
  41. end
  42. if speed>5 then
  43. speed=5.5
  44. end
  45. pos.position=new.p
  46. if keys.w then
  47. gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(-math.rad(speed*15),0,0)
  48. elseif keys.s then
  49. gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(math.rad(speed*15),0,0)
  50. else
  51. gyro.cframe = workspace.CurrentCamera.CoordinateFrame
  52. end
  53. until not Fly
  54. if gyro then gyro:Destroy() end
  55. if pos then pos:Destroy() end
  56. flying=false
  57. localplayer.Character.Humanoid.PlatformStand=false
  58. speed=0
  59. end
  60. e1=mouse.KeyDown:connect(function(key)
  61. if not torso or not torso.Parent then flying=false e1:disconnect() e2:disconnect() return end
  62. if key=="w" then
  63. keys.w=true
  64. elseif key=="s" then
  65. keys.s=true
  66. elseif key=="a" then
  67. keys.a=true
  68. elseif key=="d" then
  69. keys.d=true
  70. end
  71. end)
  72. e2=mouse.KeyUp:connect(function(key)
  73. if key=="w" then
  74. keys.w=false
  75. elseif key=="s" then
  76. keys.s=false
  77. elseif key=="a" then
  78. keys.a=false
  79. elseif key=="d" then
  80. keys.d=false
  81. end
  82. end)
  83. start()
  84. elseif Fly == true then
  85. Fly = false
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement