local RunService = game:GetService("RunService") if not RunService:IsStudio() then return end local Players = game:GetService("Players") local Input = game:GetService("UserInputService") local player = Players.LocalPlayer local SPEED = 45 local servo, attachment local gui = Instance.new("ScreenGui") gui.Name = "StudioFlightPanel" gui.ResetOnSpawn = false gui.Parent = player:WaitForChild("PlayerGui") local button = Instance.new("TextButton") button.Size = UDim2.fromOffset(180, 44) button.Position = UDim2.new(0, 20, 1, -70) button.Text = "Flight: off" button.Parent = gui local function land() if servo then servo:Destroy(); servo = nil end if attachment then attachment:Destroy(); attachment = nil end button.Text = "Flight: off" end button.Activated:Connect(function() if servo then land(); return end local root = player.Character and player.Character:FindFirstChild("HumanoidRootPart") if not root then return end attachment = Instance.new("Attachment") attachment.Parent = root servo = Instance.new("LinearVelocity") servo.Attachment0 = attachment servo.RelativeTo = Enum.ActuatorRelativeTo.World servo.ForceLimitsEnabled = false servo.Parent = root button.Text = "Flight: on" end) local function pressed(key) return Input:IsKeyDown(key) and 1 or 0 end RunService.Heartbeat:Connect(function() local camera = workspace.CurrentCamera if not servo or not camera then return end local frame = camera.CFrame local forward = Vector3.new(frame.LookVector.X, 0, frame.LookVector.Z) forward = forward.Magnitude > 0.01 and forward.Unit or Vector3.new(0, 0, -1) local right = forward:Cross(Vector3.yAxis) local motion = forward * (pressed(Enum.KeyCode.W) - pressed(Enum.KeyCode.S)) + right * (pressed(Enum.KeyCode.D) - pressed(Enum.KeyCode.A)) + Vector3.yAxis * (pressed(Enum.KeyCode.Space) - pressed(Enum.KeyCode.LeftControl)) servo.VectorVelocity = motion.Magnitude > 0 and motion.Unit * SPEED or Vector3.zero end) player.CharacterRemoving:Connect(land)