print("[ESP] Script starting") if getgenv().__APX_ESP_CLEANUP then getgenv().__APX_ESP_CLEANUP() getgenv().__APX_ESP_CLEANUP = nil task.wait() end local Workspace = cloneref(workspace) local Players = cloneref(game:GetService("Players")) local RunService = cloneref(game:GetService("RunService")) local UserInputService = cloneref(game:GetService("UserInputService")) local LocalPlayer = Players.LocalPlayer local CurrentCamera = Workspace.CurrentCamera local Instance_new = Instance.new local UDim2_new = UDim2.new local Color3_fromRGB = Color3.fromRGB local mathFloor = math.floor local CONFIG = { MaxDistance = 500, TextColor = Color3_fromRGB(255, 255, 255), FillColor = Color3_fromRGB(255, 0, 0), OutlineColor = Color3_fromRGB(255, 0, 0), FillTransparency = 0.2, -- 0.8 opacity = 0.2 transparency OutlineTransparency = 0.5, -- 0.5 opacity = 0.5 transparency } local _enabled = true local _connections = {} local _guiObjects = {} local _espGui = gethui():FindFirstChild("APX_ESP_GUI") if _espGui then _espGui:Destroy() end _espGui = Instance_new("ScreenGui") _espGui.Name = "APX_ESP_GUI" _espGui.ResetOnSpawn = false _espGui.Parent = gethui() print("[ESP] GUI created") local function getAIModels() local world = Workspace:FindFirstChild("World") local aiFolder = world and world:FindFirstChild("AI") if not aiFolder then return {} end return aiFolder:GetChildren() end local function isAlive(model) local hum = model:FindFirstChildOfClass("Humanoid") return hum and hum.Health > 0 end local function createGuiBox(model) -- Text label local text = Instance_new("TextLabel") text.Name = "ESP_Text_" .. model.Name text.BackgroundTransparency = 1 text.TextColor3 = CONFIG.TextColor text.TextSize = 12 text.Font = Enum.Font.GothamBold text.TextXAlignment = Enum.TextXAlignment.Center text.TextStrokeTransparency = 0.5 text.TextStrokeColor3 = Color3_fromRGB(0, 0, 0) text.Size = UDim2_new(0, 200, 0, 20) text.Visible = false text.Parent = _espGui return { text = text } end local function updateESP(model, gui) if not model.Parent or not isAlive(model) then gui.text.Visible = false return end local root = model:FindFirstChild("HumanoidRootPart") if not root then gui.text.Visible = false return end local myChar = LocalPlayer.Character if not myChar then gui.text.Visible = false return end local myRoot = myChar:FindFirstChild("HumanoidRootPart") if not myRoot then gui.text.Visible = false return end local dist = (root.Position - myRoot.Position).Magnitude if dist > CONFIG.MaxDistance then gui.text.Visible = false return end local rootScreenPos, onScreen = CurrentCamera:WorldToViewportPoint(root.Position) if rootScreenPos.Z <= 0 then gui.text.Visible = false return end if not onScreen then gui.text.Visible = false return end local vp = CurrentCamera.ViewportSize local rootX = mathFloor(rootScreenPos.X) local rootY = mathFloor(rootScreenPos.Y) local textY = rootY - 40 local head = model:FindFirstChild("Head") if head then local headScreenPos = CurrentCamera:WorldToViewportPoint(head.Position) if headScreenPos.Z > 0 then textY = mathFloor(headScreenPos.Y) - 22 end end gui.text.Position = UDim2_new(0, rootX - 100, 0, textY) local hum = model:FindFirstChildOfClass("Humanoid") local health = hum and mathFloor(hum.Health) or 0 local maxHealth = hum and mathFloor(hum.MaxHealth) or 100 gui.text.Text = model.Name .. " " .. health .. "/" .. maxHealth .. " [" .. mathFloor(dist) .. "m]" gui.text.Visible = true end local _renderConn = RunService.PreRender:Connect(function() if not _enabled then for _, gui in pairs(_guiObjects) do gui.text.Visible = false end return end local aiModels = getAIModels() local seen = {} for _, model in ipairs(aiModels) do seen[model] = true if not _guiObjects[model] then _guiObjects[model] = createGuiBox(model) end updateESP(model, _guiObjects[model]) end -- Clean up stale entries for model, gui in pairs(_guiObjects) do if not seen[model] then gui.text:Destroy() _guiObjects[model] = nil end end end) table.insert(_connections, _renderConn) local function cleanup() _enabled = false for _, conn in ipairs(_connections) do conn:Disconnect() end table.clear(_connections) for _, gui in pairs(_guiObjects) do gui.text:Destroy() end table.clear(_guiObjects) if _espGui and _espGui.Parent then _espGui:Destroy() end print("[ESP] Cleaned up") end getgenv().__APX_ESP_CLEANUP = cleanup local _inputConn = UserInputService.InputBegan:Connect(function(input, gpe) if gpe then return end if input.KeyCode == Enum.KeyCode.Delete then cleanup() end end) table.insert(_connections, _inputConn) print("[ESP] Ready")