local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local RunService = game:GetService("RunService") local camera = workspace.CurrentCamera local localPlayer = Players.LocalPlayer local target = nil local isLocked = false -- Función para encontrar al enemigo más cercano a la mira local function getClosestPlayer() local closest = nil local shortestDistance = math.huge local mousePos = UIS:GetMouseLocation() for _, p in pairs(Players:GetPlayers()) do if p ~= localPlayer and p.Character and p.Character:FindFirstChild("Head") then local head = p.Character.Head local pos, onScreen = camera:WorldToViewportPoint(head.Position) if onScreen then local distance = (Vector2.new(pos.X, pos.Y) - mousePos).Magnitude if distance < shortestDistance then closest = p shortestDistance = distance end end end end return closest end -- Función para el Cuadrado Verde (ESP) local function applyESP(p) if p.Character and not p.Character:FindFirstChild("GreenBox") then local highlight = Instance.new("Highlight") highlight.Name = "GreenBox" highlight.Parent = p.Character highlight.FillColor = Color3.fromRGB(0, 255, 0) -- Verde highlight.OutlineColor = Color3.fromRGB(255, 255, 255) highlight.FillTransparency = 0.5 end end -- Bucle principal: Fijar cabeza y actualizar ESP RunService.RenderStepped:Connect(function() -- Dibujar ESP en todos for _, p in pairs(Players:GetPlayers()) do if p ~= localPlayer then applyESP(p) end end -- Si está bloqueado, clavar la cámara en la cabeza if isLocked and target and target.Character and target.Character:FindFirstChild("Head") then camera.CFrame = CFrame.new(camera.CFrame.Position, target.Character.Head.Position) end end) -- Detectar Tecla E UIS.InputBegan:Connect(function(input, processed) if processed then return end if input.KeyCode == Enum.KeyCode.E then if not isLocked then target = getClosestPlayer() if target then isLocked = true end else isLocked = false target = nil end end end)