-- LocalScript under StarterGui (only one script needed) local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local UIS = game:GetService("UserInputService") local runService = game:GetService("RunService") -- GUI creation local screenGui = Instance.new("ScreenGui") screenGui.Name = "FlyGui" screenGui.ResetOnSpawn = false screenGui.Parent = player:WaitForChild("PlayerGui") local button = Instance.new("TextButton") button.Size = UDim2.new(0, 120, 0, 40) button.Position = UDim2.new(0.5, -60, 0.5, -20) button.Text = "Fly Mode" button.BackgroundColor3 = Color3.fromRGB(0, 170, 255) button.TextColor3 = Color3.new(1, 1, 1) button.Font = Enum.Font.SourceSansBold button.TextSize = 20 button.Draggable = true button.Active = true button.Parent = screenGui -- Fly logic local flying = false local flyConnection = nil local moveDir = Vector3.zero local bodyGyro, bodyVelocity local function startFlying() character = player.Character or player.CharacterAdded:Wait() humanoidRootPart = character:WaitForChild("HumanoidRootPart") bodyGyro = Instance.new("BodyGyro") bodyGyro.P = 9e4 bodyGyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9) bodyGyro.CFrame = humanoidRootPart.CFrame bodyGyro.Parent = humanoidRootPart bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.Velocity = Vector3.new(0, 0, 0) bodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9) bodyVelocity.Parent = humanoidRootPart local speed = 50 flyConnection = runService.Heartbeat:Connect(function() bodyGyro.CFrame = workspace.CurrentCamera.CFrame bodyVelocity.Velocity = workspace.CurrentCamera.CFrame:VectorToWorldSpace(moveDir) * speed end) end local function stopFlying() if flyConnection then flyConnection:Disconnect() end if bodyGyro then bodyGyro:Destroy() end if bodyVelocity then bodyVelocity:Destroy() end moveDir = Vector3.zero end UIS.InputBegan:Connect(function(input, gpe) if gpe then return end if input.KeyCode == Enum.KeyCode.W then moveDir = Vector3.new(0, 0, -1) end if input.KeyCode == Enum.KeyCode.S then moveDir = Vector3.new(0, 0, 1) end if input.KeyCode == Enum.KeyCode.A then moveDir = Vector3.new(-1, 0, 0) end if input.KeyCode == Enum.KeyCode.D then moveDir = Vector3.new(1, 0, 0) end if input.KeyCode == Enum.KeyCode.Space then moveDir = Vector3.new(0, 1, 0) end end) UIS.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard then moveDir = Vector3.zero end end) button.MouseButton1Click:Connect(function() flying = not flying if flying then startFlying() button.Text = "Stop Flying" else stopFlying() button.Text = "Fly Mode" end end)