--// Services local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") --// Variables local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local flying = false local speed = 50 --// GUI Setup local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "FlyGui" ScreenGui.Parent = player.PlayerGui local FlyButton = Instance.new("TextButton") FlyButton.Size = UDim2.new(0, 100, 0, 30) FlyButton.Position = UDim2.new(0, 10, 0, 10) FlyButton.Text = "Fly" FlyButton.BackgroundColor3 = Color3.new(0, 0.5, 1) FlyButton.Parent = ScreenGui --// Fly Function local function Fly() if flying then flying = false humanoid.WalkSpeed = 16 humanoid.JumpPower = 50 FlyButton.Text = "Fly" else flying = true humanoid.WalkSpeed = 0 humanoid.JumpPower = 0 FlyButton.Text = "Stop Flying" repeat character:MoveTo(character.HumanoidRootPart.Position + Vector3.new(0, 0.1, 0)) -- Keep character grounded slightly RunService.RenderStepped:Wait() -- Wait for the next frame until not flying humanoid.WalkSpeed = 16 -- Restore walk speed humanoid.JumpPower = 50 -- Restore jump power end end --// Button Clicked Event FlyButton.MouseButton1Click:Connect(Fly) --// Keybind (optional) UserInputService.InputBegan:Connect(function(input, gameProcessedEvent) if gameProcessedEvent then return end if input.KeyCode == Enum.KeyCode.F then -- Change "F" to your desired key Fly() end end) --// Movement when flying local RunService = game:GetService("RunService") RunService.RenderStepped:Connect(function(deltaTime) if flying then humanoid.PlatformStand = true -- prevent falling local direction = Vector3.new(0,0,0) if UserInputService:IsKeyDown(Enum.KeyCode.W) then direction = direction + character.HumanoidRootPart.CFrame.LookVector end if UserInputService:IsKeyDown(Enum.KeyCode.S) then direction = direction - character.HumanoidRootPart.CFrame.LookVector end if UserInputService:IsKeyDown(Enum.KeyCode.A) then direction = direction - character.HumanoidRootPart.CFrame.RightVector end if UserInputService:IsKeyDown(Enum.KeyCode.D) then direction = direction + character.HumanoidRootPart.CFrame.RightVector end if UserInputService:IsKeyDown(Enum.KeyCode.Space) then direction = direction + Vector3.new(0,1,0) end if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then direction = direction - Vector3.new(0,1,0) end character:MoveTo(character.HumanoidRootPart.Position + direction * speed * deltaTime) else humanoid.PlatformStand = false end end)