Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local Workspace = game:GetService("Workspace")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local hrp = character:WaitForChild("HumanoidRootPart")
- local camera = Workspace.CurrentCamera
- local flySpeed = 50
- local isFlying = false
- local bodyVelocity = nil
- local upPressed, downPressed = false, false
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "FlyUI"
- screenGui.ResetOnSpawn = false
- screenGui.Parent = player:WaitForChild("PlayerGui")
- local mainFrame = Instance.new("Frame")
- mainFrame.Size = UDim2.new(0, 150, 0, 120)
- mainFrame.Position = UDim2.new(1, -160, 1, -140)
- mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- mainFrame.Active = true
- mainFrame.Draggable = true
- mainFrame.Parent = screenGui
- Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0, 12)
- local toggle = Instance.new("TextButton")
- toggle.Size = UDim2.new(1, -10, 0, 40)
- toggle.Position = UDim2.new(0, 5, 0, 5)
- toggle.Text = "FLY: OFF"
- toggle.BackgroundColor3 = Color3.fromRGB(100, 150, 255)
- toggle.TextColor3 = Color3.new(1, 1, 1)
- toggle.Font = Enum.Font.GothamBold
- toggle.TextScaled = true
- toggle.Parent = mainFrame
- local upBtn = Instance.new("TextButton")
- upBtn.Size = UDim2.new(0.48, 0, 0, 30)
- upBtn.Position = UDim2.new(0.02, 0, 0, 50)
- upBtn.Text = "⬆️"
- upBtn.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
- upBtn.TextColor3 = Color3.new(1, 1, 1)
- upBtn.Font = Enum.Font.GothamBold
- upBtn.TextScaled = true
- upBtn.Parent = mainFrame
- Instance.new("UICorner", upBtn).CornerRadius = UDim.new(0, 6)
- local downBtn = Instance.new("TextButton")
- downBtn.Size = UDim2.new(0.48, 0, 0, 30)
- downBtn.Position = UDim2.new(0.5, 0, 0, 50)
- downBtn.Text = "⬇️"
- downBtn.BackgroundColor3 = Color3.fromRGB(255, 100, 100)
- downBtn.TextColor3 = Color3.new(1, 1, 1)
- downBtn.Font = Enum.Font.GothamBold
- downBtn.TextScaled = true
- downBtn.Parent = mainFrame
- Instance.new("UICorner", downBtn).CornerRadius = UDim.new(0, 6)
- local function startFlying()
- if isFlying then return end
- isFlying = true
- bodyVelocity = Instance.new("BodyVelocity")
- bodyVelocity.Velocity = Vector3.zero
- bodyVelocity.MaxForce = Vector3.new(4000, 4000, 4000)
- bodyVelocity.P = 1250
- bodyVelocity.Parent = hrp
- toggle.Text = "FLY: ON"
- end
- local function stopFlying()
- isFlying = false
- if bodyVelocity then
- bodyVelocity:Destroy()
- bodyVelocity = nil
- end
- toggle.Text = "FLY: OFF"
- end
- toggle.MouseButton1Click:Connect(function()
- if isFlying then
- stopFlying()
- else
- startFlying()
- end
- end)
- upBtn.MouseButton1Down:Connect(function() upPressed = true end)
- upBtn.MouseButton1Up:Connect(function() upPressed = false end)
- downBtn.MouseButton1Down:Connect(function() downPressed = true end)
- downBtn.MouseButton1Up:Connect(function() downPressed = false end)
- RunService.Heartbeat:Connect(function()
- if isFlying and bodyVelocity and hrp then
- local camLook = camera.CFrame.LookVector
- local forward = Vector3.new(camLook.X, 0, camLook.Z).Unit * flySpeed
- local verticalVelocity = 0
- if upPressed then verticalVelocity = flySpeed end
- if downPressed then verticalVelocity = -flySpeed end
- bodyVelocity.Velocity = forward + Vector3.new(0, verticalVelocity, 0)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment