local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local rotationSpeed = 5 -- скорость поворота камеры local function getNearestEnemy() local character = player.Character if not character then return nil end local rootPart = character:FindFirstChild("HumanoidRootPart") if not rootPart then return nil end local closestPlayer = nil local closestDistance = math.huge for _, otherPlayer in pairs(Players:GetPlayers()) do if otherPlayer ~= player and otherPlayer.Character then local otherRoot = otherPlayer.Character:FindFirstChild("HumanoidRootPart") if otherRoot then local dist = (otherRoot.Position - rootPart.Position).Magnitude if dist < closestDistance then closestDistance = dist closestPlayer = otherPlayer end end end end return closestPlayer end RunService.RenderStepped:Connect(function(dt) local targetPlayer = getNearestEnemy() if targetPlayer and targetPlayer.Character then local targetRoot = targetPlayer.Character:FindFirstChild("HumanoidRootPart") if targetRoot then local camPos = camera.CFrame.Position local targetPos = targetRoot.Position local direction = (targetPos - camPos).Unit local currentLook = camera.CFrame.LookVector -- Плавно поворачиваем камеру к цели local newLook = currentLook:Lerp(direction, math.clamp(rotationSpeed * dt, 0, 1)) camera.CFrame = CFrame.new(camPos, camPos + newLook) end end end)