Player Highlights Esp
Key RequiredUniversal

Player Highlights Esp

Universal ScriptPnsdgPnsdg 742 views 422 executesUpdated Dec 5, 2025
Unrated
00
Lua Script•169 lines (4535 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer

local featureStates = {
    PlayerHighlights = true
}

local HighlightsConnection = nil
local cachedPlayers = {}
local lastPlayerCacheUpdate = 0
local isRendering = true
local windowFocused = true

local function getOutlineColor(fillColor)
    return Color3.new(
        math.clamp(fillColor.R * 0.7, 0, 1),
        math.clamp(fillColor.G * 0.7, 0, 1),
        math.clamp(fillColor.B * 0.7, 0, 1)
    )
end

local function IsAlive(plr)
    local character = plr.Character
    if not character then return false end
    
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if not humanoid then return false end
    
    return humanoid.Health > 0
end

function getCachedPlayers()
    if tick() - lastPlayerCacheUpdate < 1 then
        return cachedPlayers
    end
    
    lastPlayerCacheUpdate = tick()
    cachedPlayers = Players:GetPlayers()
    return cachedPlayers
end

function clearAllHighlights()
    for _, plr in pairs(getCachedPlayers()) do
        if plr.Character then
            local highlight = plr.Character:FindFirstChild("PlayerHighlight")
            if highlight then
                highlight:Destroy()
            end
        end
    end
end

function updateRoleHighlights()
    if not isRendering or not windowFocused then
        return
    end
    
    local players = getCachedPlayers()

    for _, plr in ipairs(players) do
        if plr ~= player and plr.Character then
            local model = plr.Character
            local highlight = model:FindFirstChild("PlayerHighlight")
            local highlightEnabled = featureStates.PlayerHighlights
            
            if highlightEnabled then
                local isAlive = IsAlive(plr)
                local color = isAlive and Color3.fromRGB(0, 225, 0) or Color3.fromRGB(150, 150, 150)
                local outlineColor = getOutlineColor(color)
                
                if not highlight then
                    highlight = Instance.new("Highlight")
                    highlight.Name = "PlayerHighlight"
                    highlight.Adornee = model
                    highlight.FillTransparency = 0.5
                    highlight.OutlineTransparency = 0
                    highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
                    highlight.Parent = model
                end
                highlight.FillColor = color
                highlight.OutlineColor = outlineColor
            else
                if highlight then
                    highlight:Destroy()
                end
            end
        end
    end
end

function startHighlights()
    if not HighlightsConnection then
        HighlightsConnection = RunService.Heartbeat:Connect(updateRoleHighlights)
    end
end

function stopHighlights()
    if HighlightsConnection then
        HighlightsConnection:Disconnect()
        HighlightsConnection = nil
        clearAllHighlights()
    end
end

RunService.RenderStepped:Connect(function()
    isRendering = true
end)

local lastRenderTime = tick()
local renderCheckConnection = RunService.Heartbeat:Connect(function()
    local currentTime = tick()
    
    if currentTime - lastRenderTime > 1 then
        isRendering = false
        clearAllHighlights()
    end
end)

RunService.RenderStepped:Connect(function()
    lastRenderTime = tick()
    isRendering = true
end)

UserInputService.WindowFocusReleased:Connect(function()
    windowFocused = false
    isRendering = false
    clearAllHighlights()
end)

UserInputService.WindowFocused:Connect(function()
    windowFocused = true
    isRendering = true
end)

game:GetService("GuiService"):GetPropertyChangedSignal("MenuIsOpen"):Connect(function()
    if game:GetService("GuiService").MenuIsOpen then
        isRendering = false
        clearAllHighlights()
    else
        isRendering = true
    end
end)

startHighlights()

Players.PlayerRemoving:Connect(function(plr)
    if plr.Character then
        local highlight = plr.Character:FindFirstChild("PlayerHighlight")
        if highlight then
            highlight:Destroy()
        end
    end
end)

local function cleanup()
    stopHighlights()
    if renderCheckConnection then
        renderCheckConnection:Disconnect()
    end
end

game:GetService("ScriptContext").DescendantRemoving:Connect(function(descendant)
    if descendant == script then
        cleanup()
    end
end)

Features & Information

Automatically reload when your game run in the background no missing highlights bug

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts