Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. local LocalPlayer = game:GetService("Players").LocalPlayer
  2. local Mouse = LocalPlayer:GetMouse()
  3. local WingsButton = game:GetService("ReplicatedStorage"):FindFirstChild("Wings_Button")
  4. local OldVariable, Variable
  5. local TiltAngle = 0
  6. local Keys = {}
  7. local Active = false
  8. local Camera = workspace.CurrentCamera
  9. local Player = game.Players.LocalPlayer
  10. local MaxSpeed = 4
  11. local TurnSpeed = 1
  12. local IncrementSpeed = 0.01
  13. local CurrentSpeed = 0
  14. local userinput = game:GetService("UserInputService")
  15. local Character
  16. do
  17. local r, c = pcall(function()
  18. return Player.Character
  19. end)
  20. if r then
  21. if 0 < #c:GetChildren() then
  22. Character = c
  23. else
  24. return error("[ParticleWings]: Owner of the wings had no character, script terminated.", 0)
  25. end
  26. else
  27. return error("[ParticleWings]: Owner of the wings had no character, script terminated.", 0)
  28. end
  29. end
  30. local Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
  31. if Torso == nil then
  32. return error("[ParticleWings]: Owner's character had no torso, script terminated.", 0)
  33. end
  34. local Humanoid = Character:FindFirstChild("Humanoid")
  35. if Humanoid == nil then
  36. return error("[ParticleWings]: Owner's character had no humanoid, script terminated.", 0)
  37. end
  38. function NoFly()
  39. pcall(game.Destroy, Force)
  40. pcall(game.Destroy, Gyro)
  41. Humanoid.PlatformStand = false
  42. end
  43. function Fly()
  44. Force = Instance.new("BodyPosition", Torso)
  45. Force.maxForce = Vector3.new(40000000000, 40000000000, 40000000000)
  46. Force.position = Torso.Position
  47. Force.P = 100000
  48. Gyro = Instance.new("BodyGyro", Torso)
  49. Gyro.maxTorque = Vector3.new(40000000000, 40000000000, 40000000000)
  50. Gyro.cframe = Camera and Camera.CoordinateFrame or Torso.CFrame
  51. Gyro.P = 100000
  52. end
  53. function HandleFly()
  54. if Active then
  55. if not Camera then
  56. return
  57. end
  58. Humanoid.PlatformStand = true
  59. local Fake_GCF = Gyro.cframe * CFrame.Angles(0, -TiltAngle, 0)
  60. Variable = Fake_GCF - Gyro.cframe.p + Force.position
  61. local ChangedSpeed = false
  62. local Tilted = false
  63. local Moved = false
  64. if Keys[Enum.KeyCode.W] or Keys[Enum.KeyCode.Up] then
  65. Moved = true
  66. ChangedSpeed = true
  67. Variable = Variable + Camera.CoordinateFrame.lookVector * CurrentSpeed
  68. end
  69. if Keys[Enum.KeyCode.S] or Keys[Enum.KeyCode.Down] then
  70. Moved = true
  71. ChangedSpeed = true
  72. Variable = Variable - Camera.CoordinateFrame.lookVector * CurrentSpeed
  73. end
  74. if Keys[Enum.KeyCode.D] then
  75. Moved = true
  76. Tilted = "Right"
  77. Variable = Variable * CFrame.new(CurrentSpeed, 0, 0)
  78. end
  79. if Keys[Enum.KeyCode.A] then
  80. Moved = true
  81. Tilted = "Left"
  82. Variable = Variable * CFrame.new(-CurrentSpeed, 0, 0)
  83. end
  84. if Moved then
  85. if CurrentSpeed == 0 then
  86. CurrentSpeed = 1
  87. end
  88. if OldVariable ~= Variable then
  89. Force.position = Variable.p
  90. OldVariable = Variable
  91. if ChangedSpeed then
  92. CurrentSpeed = math.min(CurrentSpeed + CurrentSpeed * IncrementSpeed, MaxSpeed)
  93. end
  94. end
  95. else
  96. CurrentSpeed = 0
  97. end
  98. TiltAngle = 0
  99. if Tilted then
  100. if Tilted:lower() == "right" then
  101. TiltAngle = -math.rad(45)
  102. elseif Tilted:lower() == "left" then
  103. TiltAngle = math.rad(45)
  104. end
  105. end
  106. local NewCF = Camera.CoordinateFrame * CFrame.Angles(-math.rad(90 * (CurrentSpeed / MaxSpeed)), TiltAngle, 0)
  107. Gyro.cframe = Gyro.cframe:lerp(NewCF, 0.2)
  108. end
  109. end
  110. local codes = {
  111. Enum.KeyCode.W,
  112. Enum.KeyCode.A,
  113. Enum.KeyCode.S,
  114. Enum.KeyCode.D,
  115. Enum.KeyCode.Up,
  116. Enum.KeyCode.Down
  117. }
  118. userinput.InputBegan:connect(function(input)
  119. if input.KeyCode == Enum.KeyCode.Q then
  120. elseif input.KeyCode == Enum.KeyCode.E then
  121. if Active then
  122. NoFly()
  123. else
  124. Fly()
  125. end
  126. Active = not Active
  127. else
  128. for a, d in pairs(codes) do
  129. if input.KeyCode == d then
  130. Keys[input.KeyCode] = input.KeyCode
  131. end
  132. end
  133. end
  134. end)
  135. userinput.InputEnded:connect(function(input)
  136. for a, d in pairs(codes) do
  137. if input.KeyCode == d then
  138. Keys[input.KeyCode] = nil
  139. end
  140. end
  141. end)
  142. SteppedEvent = game:GetService("RunService").RenderStepped:connect(function()
  143. HandleFly()
  144. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement