Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LocalPlayer = game:GetService("Players").LocalPlayer
- local Mouse = LocalPlayer:GetMouse()
- local WingsButton = game:GetService("ReplicatedStorage"):FindFirstChild("Wings_Button")
- local OldVariable, Variable
- local TiltAngle = 0
- local Keys = {}
- local Active = false
- local Camera = workspace.CurrentCamera
- local Player = game.Players.LocalPlayer
- local MaxSpeed = 4
- local TurnSpeed = 1
- local IncrementSpeed = 0.01
- local CurrentSpeed = 0
- local userinput = game:GetService("UserInputService")
- local Character
- do
- local r, c = pcall(function()
- return Player.Character
- end)
- if r then
- if 0 < #c:GetChildren() then
- Character = c
- else
- return error("[ParticleWings]: Owner of the wings had no character, script terminated.", 0)
- end
- else
- return error("[ParticleWings]: Owner of the wings had no character, script terminated.", 0)
- end
- end
- local Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
- if Torso == nil then
- return error("[ParticleWings]: Owner's character had no torso, script terminated.", 0)
- end
- local Humanoid = Character:FindFirstChild("Humanoid")
- if Humanoid == nil then
- return error("[ParticleWings]: Owner's character had no humanoid, script terminated.", 0)
- end
- function NoFly()
- pcall(game.Destroy, Force)
- pcall(game.Destroy, Gyro)
- Humanoid.PlatformStand = false
- end
- function Fly()
- Force = Instance.new("BodyPosition", Torso)
- Force.maxForce = Vector3.new(40000000000, 40000000000, 40000000000)
- Force.position = Torso.Position
- Force.P = 100000
- Gyro = Instance.new("BodyGyro", Torso)
- Gyro.maxTorque = Vector3.new(40000000000, 40000000000, 40000000000)
- Gyro.cframe = Camera and Camera.CoordinateFrame or Torso.CFrame
- Gyro.P = 100000
- end
- function HandleFly()
- if Active then
- if not Camera then
- return
- end
- Humanoid.PlatformStand = true
- local Fake_GCF = Gyro.cframe * CFrame.Angles(0, -TiltAngle, 0)
- Variable = Fake_GCF - Gyro.cframe.p + Force.position
- local ChangedSpeed = false
- local Tilted = false
- local Moved = false
- if Keys[Enum.KeyCode.W] or Keys[Enum.KeyCode.Up] then
- Moved = true
- ChangedSpeed = true
- Variable = Variable + Camera.CoordinateFrame.lookVector * CurrentSpeed
- end
- if Keys[Enum.KeyCode.S] or Keys[Enum.KeyCode.Down] then
- Moved = true
- ChangedSpeed = true
- Variable = Variable - Camera.CoordinateFrame.lookVector * CurrentSpeed
- end
- if Keys[Enum.KeyCode.D] then
- Moved = true
- Tilted = "Right"
- Variable = Variable * CFrame.new(CurrentSpeed, 0, 0)
- end
- if Keys[Enum.KeyCode.A] then
- Moved = true
- Tilted = "Left"
- Variable = Variable * CFrame.new(-CurrentSpeed, 0, 0)
- end
- if Moved then
- if CurrentSpeed == 0 then
- CurrentSpeed = 1
- end
- if OldVariable ~= Variable then
- Force.position = Variable.p
- OldVariable = Variable
- if ChangedSpeed then
- CurrentSpeed = math.min(CurrentSpeed + CurrentSpeed * IncrementSpeed, MaxSpeed)
- end
- end
- else
- CurrentSpeed = 0
- end
- TiltAngle = 0
- if Tilted then
- if Tilted:lower() == "right" then
- TiltAngle = -math.rad(45)
- elseif Tilted:lower() == "left" then
- TiltAngle = math.rad(45)
- end
- end
- local NewCF = Camera.CoordinateFrame * CFrame.Angles(-math.rad(90 * (CurrentSpeed / MaxSpeed)), TiltAngle, 0)
- Gyro.cframe = Gyro.cframe:lerp(NewCF, 0.2)
- end
- end
- local codes = {
- Enum.KeyCode.W,
- Enum.KeyCode.A,
- Enum.KeyCode.S,
- Enum.KeyCode.D,
- Enum.KeyCode.Up,
- Enum.KeyCode.Down
- }
- userinput.InputBegan:connect(function(input)
- if input.KeyCode == Enum.KeyCode.Q then
- elseif input.KeyCode == Enum.KeyCode.E then
- if Active then
- NoFly()
- else
- Fly()
- end
- Active = not Active
- else
- for a, d in pairs(codes) do
- if input.KeyCode == d then
- Keys[input.KeyCode] = input.KeyCode
- end
- end
- end
- end)
- userinput.InputEnded:connect(function(input)
- for a, d in pairs(codes) do
- if input.KeyCode == d then
- Keys[input.KeyCode] = nil
- end
- end
- end)
- SteppedEvent = game:GetService("RunService").RenderStepped:connect(function()
- HandleFly()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement