-- FlyGui LocalScript -- Put this in: StarterPlayer > StarterPlayerScripts (as a LocalScript) local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera -- Settings local flySpeed = 50 local MIN_SPEED, MAX_SPEED = 1, 1000 local flying = false local flyConnection local bodyVelocity, bodyGyro -- ========== GUI ========== local screenGui = Instance.new("ScreenGui") screenGui.Name = "FlyGui" screenGui.ResetOnSpawn = false screenGui.Parent = player:WaitForChild("PlayerGui") local mainFrame = Instance.new("Frame") mainFrame.Name = "Main" mainFrame.Size = UDim2.new(0, 260, 0, 150) mainFrame.Position = UDim2.new(0.5, -130, 0.4, 0) mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 38) mainFrame.BorderSizePixel = 0 mainFrame.ClipsDescendants = true mainFrame.Parent = screenGui Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0, 8) -- Title bar (drag handle) local titleBar = Instance.new("Frame") titleBar.Name = "TitleBar" titleBar.Size = UDim2.new(1, 0, 0, 30) titleBar.BackgroundColor3 = Color3.fromRGB(45, 45, 58) titleBar.BorderSizePixel = 0 titleBar.Parent = mainFrame local title = Instance.new("TextLabel") title.Size = UDim2.new(1, -80, 1, 0) title.Position = UDim2.new(0, 10, 0, 0) title.BackgroundTransparency = 1 title.Text = "Fly GUI" title.TextColor3 = Color3.new(1, 1, 1) title.Font = Enum.Font.GothamBold title.TextSize = 14 title.TextXAlignment = Enum.TextXAlignment.Left title.Parent = titleBar -- Close (X) button - top right local closeBtn = Instance.new("TextButton") closeBtn.Name = "Close" closeBtn.Size = UDim2.new(0, 30, 0, 30) closeBtn.Position = UDim2.new(1, -30, 0, 0) closeBtn.BackgroundColor3 = Color3.fromRGB(200, 60, 60) closeBtn.BorderSizePixel = 0 closeBtn.Text = "X" closeBtn.TextColor3 = Color3.new(1, 1, 1) closeBtn.Font = Enum.Font.GothamBold closeBtn.TextSize = 14 closeBtn.Parent = titleBar -- Minimize (-) button - next to X local minBtn = Instance.new("TextButton") minBtn.Name = "Minimize" minBtn.Size = UDim2.new(0, 30, 0, 30) minBtn.Position = UDim2.new(1, -60, 0, 0) minBtn.BackgroundColor3 = Color3.fromRGB(90, 90, 110) minBtn.BorderSizePixel = 0 minBtn.Text = "-" minBtn.TextColor3 = Color3.new(1, 1, 1) minBtn.Font = Enum.Font.GothamBold minBtn.TextSize = 18 minBtn.Parent = titleBar -- Content area local content = Instance.new("Frame") content.Name = "Content" content.Size = UDim2.new(1, 0, 1, -30) content.Position = UDim2.new(0, 0, 0, 30) content.BackgroundTransparency = 1 content.Parent = mainFrame local speedLabel = Instance.new("TextLabel") speedLabel.Size = UDim2.new(0, 90, 0, 30) speedLabel.Position = UDim2.new(0, 15, 0, 15) speedLabel.BackgroundTransparency = 1 speedLabel.Text = "Fly Speed:" speedLabel.TextColor3 = Color3.new(1, 1, 1) speedLabel.Font = Enum.Font.Gotham speedLabel.TextSize = 14 speedLabel.TextXAlignment = Enum.TextXAlignment.Left speedLabel.Parent = content local speedBox = Instance.new("TextBox") speedBox.Name = "SpeedBox" speedBox.Size = UDim2.new(0, 120, 0, 30) speedBox.Position = UDim2.new(0, 120, 0, 15) speedBox.BackgroundColor3 = Color3.fromRGB(55, 55, 70) speedBox.BorderSizePixel = 0 speedBox.Text = tostring(flySpeed) speedBox.PlaceholderText = "Type speed" speedBox.TextColor3 = Color3.new(1, 1, 1) speedBox.Font = Enum.Font.Gotham speedBox.TextSize = 14 speedBox.ClearTextOnFocus = false speedBox.Parent = content Instance.new("UICorner", speedBox).CornerRadius = UDim.new(0, 6) local flyBtn = Instance.new("TextButton") flyBtn.Name = "FlyToggle" flyBtn.Size = UDim2.new(1, -30, 0, 38) flyBtn.Position = UDim2.new(0, 15, 0, 62) flyBtn.BackgroundColor3 = Color3.fromRGB(200, 60, 60) flyBtn.BorderSizePixel = 0 flyBtn.Text = "Fly: OFF" flyBtn.TextColor3 = Color3.new(1, 1, 1) flyBtn.Font = Enum.Font.GothamBold flyBtn.TextSize = 16 flyBtn.Parent = content Instance.new("UICorner", flyBtn).CornerRadius = UDim.new(0, 6) -- ========== FLY LOGIC ========== local function getCharacterParts() local char = player.Character if not char then return end local root = char:FindFirstChild("HumanoidRootPart") local hum = char:FindFirstChildOfClass("Humanoid") return char, root, hum end local function stopFly() flying = false if flyConnection then flyConnection:Disconnect() flyConnection = nil end if bodyVelocity then bodyVelocity:Destroy() bodyVelocity = nil end if bodyGyro then bodyGyro:Destroy() bodyGyro = nil end local _, _, hum = getCharacterParts() if hum then hum.PlatformStand = false end flyBtn.Text = "Fly: OFF" flyBtn.BackgroundColor3 = Color3.fromRGB(200, 60, 60) end local function startFly() local _, root, hum = getCharacterParts() if not root or not hum then return end flying = true hum.PlatformStand = true bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.MaxForce = Vector3.new(1e9, 1e9, 1e9) bodyVelocity.Velocity = Vector3.zero bodyVelocity.Parent = root bodyGyro = Instance.new("BodyGyro") bodyGyro.MaxTorque = Vector3.new(1e9, 1e9, 1e9) bodyGyro.P = 9e4 bodyGyro.CFrame = camera.CFrame bodyGyro.Parent = root flyBtn.Text = "Fly: ON" flyBtn.BackgroundColor3 = Color3.fromRGB(60, 180, 90) flyConnection = RunService.RenderStepped:Connect(function() local _, r, h = getCharacterParts() if not r or not h or not bodyVelocity then stopFly() return end camera = workspace.CurrentCamera local camCF = camera.CFrame local direction = Vector3.zero -- WASD / mobile thumbstick (relative to where the camera looks) local moveDir = h.MoveDirection if moveDir.Magnitude > 0 then local flatLook = Vector3.new(camCF.LookVector.X, 0, camCF.LookVector.Z) local flatRight = Vector3.new(camCF.RightVector.X, 0, camCF.RightVector.Z) if flatLook.Magnitude > 0.001 then flatLook = flatLook.Unit end if flatRight.Magnitude > 0.001 then flatRight = flatRight.Unit end local forwardAmt = moveDir:Dot(flatLook) local rightAmt = moveDir:Dot(flatRight) direction = camCF.LookVector * forwardAmt + camCF.RightVector * rightAmt end -- Up / down (only when not typing in a textbox) if not UserInputService:GetFocusedTextBox() then if UserInputService:IsKeyDown(Enum.KeyCode.Space) then direction += Vector3.new(0, 1, 0) end if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) or UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then direction -= Vector3.new(0, 1, 0) end end if direction.Magnitude > 0 then direction = direction.Unit end bodyVelocity.Velocity = direction * flySpeed bodyGyro.CFrame = camCF end) end local function toggleFly() if flying then stopFly() else startFly() end end -- ========== BUTTON EVENTS ========== flyBtn.MouseButton1Click:Connect(toggleFly) speedBox.FocusLost:Connect(function() local value = tonumber(speedBox.Text) if value then flySpeed = math.clamp(value, MIN_SPEED, MAX_SPEED) end speedBox.Text = tostring(flySpeed) -- reset invalid input to the current speed end) local minimized = false minBtn.MouseButton1Click:Connect(function() minimized = not minimized content.Visible = not minimized mainFrame.Size = minimized and UDim2.new(0, 260, 0, 30) or UDim2.new(0, 260, 0, 150) minBtn.Text = minimized and "+" or "-" end) closeBtn.MouseButton1Click:Connect(function() stopFly() screenGui:Destroy() end) -- Turn fly off if the character respawns player.CharacterAdded:Connect(function() if flying then stopFly() end end) -- ========== DRAGGING ========== local dragging, dragStart, startPos titleBar.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = true dragStart = input.Position startPos = mainFrame.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end) end end) UserInputService.InputChanged:Connect(function(input) if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then local delta = input.Position - dragStart mainFrame.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end)