zachhy

new fly

Jul 13th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1.  
  2. mouse=game.Players.LocalPlayer:GetMouse''
  3. localplayer=game.Players.LocalPlayer
  4. game.Players.LocalPlayer.Character:WaitForChild("Torso")
  5. local torso = game.Players.LocalPlayer.Character.Torso
  6. local flying = true
  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=5
  25. end
  26. if keys.w then
  27. new = new + workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  28. speed=speed+1
  29. end
  30. if keys.s then
  31. new = new - workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  32. speed=speed+1
  33. end
  34. if keys.d then
  35. new = new * CFrame.new(speed,0,0)
  36. speed=speed+1
  37. end
  38. if keys.a then
  39. new = new * CFrame.new(-speed,0,0)
  40. speed=speed+1
  41. end
  42. if speed>5 then
  43. speed=10
  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 flying==false
  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. elseif key=="e" then
  71. if flying==true then
  72. flying=false
  73. else
  74. flying=true
  75. start()
  76. end
  77. end
  78. end)
  79. e2=mouse.KeyUp:connect(function(key)
  80. if key=="w" then
  81. keys.w=false
  82. elseif key=="s" then
  83. keys.s=false
  84. elseif key=="a" then
  85. keys.a=false
  86. elseif key=="d" then
  87. keys.d=false
  88. end
  89. end)
Add Comment
Please, Sign In to add comment