local flying = false local speed = 2 local RunService = game:GetService("RunService") local UIS = game:GetService("UserInputService") local bv, bg local function startFly() local char = player.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") if not hrp then return end bv = Instance.new("BodyVelocity", hrp) bv.MaxForce = Vector3.new(1,1,1) * 1e9 bv.Velocity = Vector3.zero bg = Instance.new("BodyGyro", hrp) bg.MaxTorque = Vector3.new(1,1,1) * 1e9 bg.CFrame = hrp.CFrame RunService:BindToRenderStep("Fly", 0, function() local cam = workspace.CurrentCamera local dir = Vector3.zero if UIS:IsKeyDown(Enum.KeyCode.W) then dir += cam.CFrame.LookVector end if UIS:IsKeyDown(Enum.KeyCode.S) then dir -= cam.CFrame.LookVector end if UIS:IsKeyDown(Enum.KeyCode.A) then dir -= cam.CFrame.RightVector end if UIS:IsKeyDown(Enum.KeyCode.D) then dir += cam.CFrame.RightVector end if UIS:IsKeyDown(Enum.KeyCode.Space) then dir += Vector3.new(0,1,0) end if UIS:IsKeyDown(Enum.KeyCode.LeftControl) then dir -= Vector3.new(0,1,0) end bv.Velocity = dir * 60 bg.CFrame = cam.CFrame end) end local function stopFly() RunService:UnbindFromRenderStep("Fly") if bv then bv:Destroy() end if bg then bg:Destroy() end end flyBtn.MouseButton1Click:Connect(function() flying = not flying flyBtn.Text = flying and "FLY: ON" or "FLY: OFF" if flying then startFly() else stopFly() end end)