-- Настройки local BASE_SPEED = 50 local SPEED_MULTIPLIER = 3 local MOUSE_SENSITIVITY = 0.2 local TOGGLE_KEY = Enum.KeyCode.P local ACCEL_KEY = Enum.KeyCode.LeftControl local SHIFT_KEYS = {Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift} local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local isActive = false local yaw = 0 local pitch = 0 local currentPosition = Vector3.zero local originalWalkSpeed = 0 local originalJumpPower = 0 local function isShiftDown() for _, key in ipairs(SHIFT_KEYS) do if UserInputService:IsKeyDown(key) then return true end end return false end local function toggleFreeCam() isActive = not isActive if isActive then local character = player.Character if character then local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then originalWalkSpeed = humanoid.WalkSpeed originalJumpPower = humanoid.JumpPower humanoid.WalkSpeed = 0 humanoid.JumpPower = 0 end end camera.CameraType = Enum.CameraType.Scriptable UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter UserInputService.MouseIconEnabled = false local cf = camera.CFrame local look = cf.LookVector yaw = math.deg(math.atan2(-look.X, -look.Z)) pitch = math.deg(math.asin(look.Y)) currentPosition = cf.Position else local character = player.Character if character then local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.WalkSpeed = originalWalkSpeed humanoid.JumpPower = originalJumpPower end end camera.CameraType = Enum.CameraType.Custom UserInputService.MouseBehavior = Enum.MouseBehavior.Default UserInputService.MouseIconEnabled = true end end UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == TOGGLE_KEY and isShiftDown() then toggleFreeCam() end end) UserInputService.InputChanged:Connect(function(input, gameProcessed) if gameProcessed then return end if not isActive then return end if input.UserInputType == Enum.UserInputType.MouseMovement then yaw = yaw - input.Delta.X * MOUSE_SENSITIVITY pitch = math.clamp(pitch - input.Delta.Y * MOUSE_SENSITIVITY, -89, 89) end end) RunService.RenderStepped:Connect(function(dt) if not isActive then return end local moveDirection = Vector3.zero if UserInputService:IsKeyDown(Enum.KeyCode.W) then moveDirection += camera.CFrame.LookVector end if UserInputService:IsKeyDown(Enum.KeyCode.S) then moveDirection -= camera.CFrame.LookVector end if UserInputService:IsKeyDown(Enum.KeyCode.A) then moveDirection -= camera.CFrame.RightVector end if UserInputService:IsKeyDown(Enum.KeyCode.D) then moveDirection += camera.CFrame.RightVector end if UserInputService:IsKeyDown(Enum.KeyCode.Q) then moveDirection += Vector3.yAxis end if UserInputService:IsKeyDown(Enum.KeyCode.E) then moveDirection -= Vector3.yAxis end if moveDirection.Magnitude > 0 then moveDirection = moveDirection.Unit end local speed = BASE_SPEED if UserInputService:IsKeyDown(ACCEL_KEY) then speed *= SPEED_MULTIPLIER end currentPosition += moveDirection * speed * dt local rotation = CFrame.fromEulerAnglesYXZ(math.rad(pitch), math.rad(yaw), 0) camera.CFrame = CFrame.new(currentPosition) * rotation end)