Advertisement
Ilkailka

TawYawdPawdawdIawdCawdawdAwadawL

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