local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local UIS = game:GetService("UserInputService") -- Wait for character and camera local character = player.Character or player.CharacterAdded:Wait() local root = character:WaitForChild("HumanoidRootPart") -- Create GUI local gui = Instance.new("ScreenGui") gui.Name = "FlyGui" gui.ResetOnSpawn = false gui.Parent = player:WaitForChild("PlayerGui") -- Create Toggle Button local button = Instance.new("TextButton") button.Size = UDim2.new(0, 100, 0, 40) button.Position = UDim2.new(0, 20, 0, 20) button.Text = "Fly: OFF" button.BackgroundColor3 = Color3.fromRGB(50, 50, 50) button.TextColor3 = Color3.new(1, 1, 1) button.Font = Enum.Font.SourceSansBold button.TextScaled = true button.Parent = gui -- Fly state and controls local flying = false local speed = 50 local bodyGyro, bodyVelocity local keys = {W = false, A = false, S = false, D = false} -- Start flying local function startFly() flying = true button.Text = "Fly: ON" bodyGyro = Instance.new("BodyGyro") bodyGyro.P = 9e4 bodyGyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9) bodyGyro.CFrame = root.CFrame bodyGyro.Parent = root bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.Velocity = Vector3.zero bodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9) bodyVelocity.Parent = root end -- Stop flying local function stopFly() flying = false button.Text = "Fly: OFF" if bodyGyro then bodyGyro:Destroy() end if bodyVelocity then bodyVelocity:Destroy() end end -- Toggle fly local function toggleFly() if flying then stopFly() else startFly() end end button.MouseButton1Click:Connect(toggleFly) -- Input tracking UIS.InputBegan:Connect(function(input, processed) if processed then return end local key = input.KeyCode.Name if keys[key] ~= nil then keys[key] = true end end) UIS.InputEnded:Connect(function(input) local key = input.KeyCode.Name if keys[key] ~= nil then keys[key] = false end end) -- Fly logic RunService.RenderStepped:Connect(function() if flying and bodyVelocity and bodyGyro then local cam = workspace.CurrentCamera local direction = Vector3.zero if keys.W then direction += cam.CFrame.LookVector end if keys.S then direction -= cam.CFrame.LookVector end if keys.A then direction -= cam.CFrame.RightVector end if keys.D then direction += cam.CFrame.RightVector end if direction.Magnitude > 0 then direction = direction.Unit bodyVelocity.Velocity = direction * speed bodyGyro.CFrame = CFrame.new(root.Position, root.Position + direction) else bodyVelocity.Velocity = Vector3.zero end end end)