Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local root = character:WaitForChild("HumanoidRootPart")
- local humanoid = character:WaitForChild("Humanoid")
- local bp;
- local bg;
- local flying = false
- local function unfly()
- flying = false
- wait()
- print('called')
- humanoid.PlatformStand = false
- if bp then
- bp:Destroy()
- end
- if bg then
- bg:Destroy()
- end
- end
- local function fly()
- flying = true
- bp = Instance.new("BodyPosition",root)
- bg = Instance.new("BodyGyro",root)
- bg.P = 12000
- bg.maxTorque = Vector3.new(math.huge,9e9,math.huge)
- bg.cframe = root.CFrame
- local function straight()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.lookVector * 25
- end
- local function back()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.lookVector * -25
- end
- local function left()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * -25
- end
- local function right()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * 25
- end
- local function cornerUp()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * 25 + workspace.CurrentCamera.CFrame.lookVector * 25
- end
- local function cornerDown()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * -25 + workspace.CurrentCamera.CFrame.lookVector * 25
- end
- local function downRight()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * 25 + workspace.CurrentCamera.CFrame.lookVector * -25
- end
- local function downLeft()
- bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * -25 + workspace.CurrentCamera.CFrame.lookVector * -25
- end
- local holdingw = false
- local holdinga = false
- local holdings = false
- local holdingd = false
- local connection = game:GetService("UserInputService").InputBegan:Connect(function(i,t)
- if not t and flying then
- if i.KeyCode == Enum.KeyCode.W then
- holdingw = true
- end
- if i.KeyCode == Enum.KeyCode.A then
- holdinga = true
- end
- if i.KeyCode == Enum.KeyCode.S then
- holdings = true
- end
- if i.KeyCode == Enum.KeyCode.D then
- holdingd = true
- end
- end
- end)
- local connection2 = game:GetService("UserInputService").InputEnded:Connect(function(i)
- if flying then
- if i.KeyCode == Enum.KeyCode.W then
- holdingw = false
- end
- if i.KeyCode == Enum.KeyCode.A then
- holdinga = false
- end
- if i.KeyCode == Enum.KeyCode.S then
- holdings = false
- end
- if i.KeyCode == Enum.KeyCode.D then
- holdingd = false
- end
- end
- end)
- spawn(function()
- while game:GetService("RunService").RenderStepped:Wait() and flying do
- bg.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(0,0,0)
- end
- end)
- spawn(function()
- while true do
- if not flying then return end
- wait()
- print('running')
- humanoid.PlatformStand = true
- if holdingw and not holdingd then
- straight()
- else
- if holdingw and holdingd then
- cornerUp()
- end
- end
- if holdinga and not holdingw and not holdings then
- left()
- else
- if holdinga and holdingw and not holdings then
- cornerDown()
- else
- if holdinga and holdings then
- downLeft()
- end
- end
- end
- if holdingd and not holdingw and not holdings then
- right()
- else
- if holdingd and holdings then
- downRight()
- end
- end
- if holdings and not holdingw and not holdinga and not holdingd and not holdinga then
- back()
- else
- if holdings and holdingd then
- downRight()
- end
- end
- end
- end)
- end
- fly()
- wait(3)
- unfly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement