Esp
Key RequiredUniversal

Esp

Universal ScriptNPCNOkNPCNOk 817 views 889 executesUpdated Oct 27, 2025
Unrated
00
Lua Script•214 lines (8626 chars)
-- Roblox ESP + Health + Improved Health Bar + Team Check
-- Toggle: Q key
-- Features: Highlights, Name/Distance/Health labels, Improved Health Bar (Rounded + Border)
-- Fixed: ESP persists on death/respawn, applies to new players, and handles team changes dynamically

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local LocalPlayer = Players.LocalPlayer
local ESPEnabled = true

-- Function to clean up ESP elements
local function cleanupESP(player, character)
    if character then
        local highlight = character:FindFirstChildOfClass("Highlight")
        if highlight then highlight:Destroy() end
        local head = character:FindFirstChild("Head")
        if head then
            local gui = head:FindFirstChildOfClass("BillboardGui")
            if gui then gui:Destroy() end
        end
    end
end

-- Function to create ESP + Improved Health Bar for a player
local function createESP(player)
    if player == LocalPlayer then return end

    local function onCharacterAdded(character)
        -- Clean up any existing ESP to prevent duplicates
        cleanupESP(player, character)

        local humanoid = character:WaitForChild("Humanoid", 5)
        local head = character:WaitForChild("Head", 5)
        local root = character:WaitForChild("HumanoidRootPart", 5)
        if not humanoid or not head or not root then return end

        -- === HIGHLIGHT ===
        local highlight = Instance.new("Highlight")
        highlight.Parent = character
        highlight.FillTransparency = 1
        highlight.OutlineColor = Color3.fromRGB(255, 0, 0)
        highlight.OutlineTransparency = 0
        highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
        highlight.Enabled = false -- Initial state; update will set based on team

        -- === BILLBOARD GUI (Name, Distance, Health, Health Bar) ===
        local billboardGui = Instance.new("BillboardGui")
        billboardGui.Parent = head
        billboardGui.Size = UDim2.new(0, 200, 0, 70) -- Compact height
        billboardGui.StudsOffset = Vector3.new(0, 3, 0)
        billboardGui.AlwaysOnTop = true
        billboardGui.Enabled = false -- Initial state; update will set based on team

        local nameLabel = Instance.new("TextLabel")
        nameLabel.Parent = billboardGui
        nameLabel.Size = UDim2.new(1, 0, 0.4, 0)
        nameLabel.BackgroundTransparency = 1
        nameLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
        nameLabel.TextStrokeTransparency = 0
        nameLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
        nameLabel.Font = Enum.Font.SourceSansBold
        nameLabel.TextSize = 16
        nameLabel.Text = player.Name

        local distanceLabel = Instance.new("TextLabel")
        distanceLabel.Parent = billboardGui
        distanceLabel.Size = UDim2.new(1, 0, 0.25, 0)
        distanceLabel.Position = UDim2.new(0, 0, 0.4, 0)
        distanceLabel.BackgroundTransparency = 1
        distanceLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
        distanceLabel.TextStrokeTransparency = 0.5
        distanceLabel.Font = Enum.Font.SourceSans
        distanceLabel.TextSize = 14

        local healthLabel = Instance.new("TextLabel")
        healthLabel.Parent = billboardGui
        healthLabel.Size = UDim2.new(1, 0, 0.2, 0)
        healthLabel.Position = UDim2.new(0, 0, 0.65, 0)
        healthLabel.BackgroundTransparency = 1
        healthLabel.TextStrokeTransparency = 0.5
        healthLabel.Font = Enum.Font.SourceSans
        healthLabel.TextSize = 14

        -- === IMPROVED HEALTH BAR ===
        local healthBarFrame = Instance.new("Frame")
        healthBarFrame.Parent = billboardGui
        healthBarFrame.Size = UDim2.new(0.6, 0, 0.05, 0) -- Smaller width (60%)
        healthBarFrame.Position = UDim2.new(0.2, 0, 0.85, 0) -- Centered horizontally
        healthBarFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50) -- Dark gray background for empty health
        healthBarFrame.BackgroundTransparency = 0.3 -- Slight transparency for subtlety
        healthBarFrame.BorderSizePixel = 0

        -- Rounded corners for background
        local bgCorner = Instance.new("UICorner")
        bgCorner.CornerRadius = UDim.new(0, 4)
        bgCorner.Parent = healthBarFrame

        -- Outline border
        local stroke = Instance.new("UIStroke")
        stroke.Color = Color3.fromRGB(255, 255, 255) -- White outline
        stroke.Thickness = 1
        stroke.Transparency = 0.5
        stroke.Parent = healthBarFrame

        local healthBarFill = Instance.new("Frame")
        healthBarFill.Parent = healthBarFrame
        healthBarFill.Size = UDim2.new(1, 0, 1, 0)
        healthBarFill.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
        healthBarFill.BorderSizePixel = 0
        healthBarFill.BackgroundTransparency = 0 -- Solid fill

        -- Rounded corners for fill
        local fillCorner = Instance.new("UICorner")
        fillCorner.CornerRadius = UDim.new(0, 4)
        fillCorner.Parent = healthBarFill

        -- Update function (handles team-based enable/disable)
        local function update()
            -- Team check: Disable if teammate
            local isTeammate = player.Team == LocalPlayer.Team and player.Team ~= nil
            if isTeammate then
                billboardGui.Enabled = false
                highlight.Enabled = false
                return
            end

            -- Enable if not teammate and conditions met
            if not ESPEnabled or not character.Parent or not humanoid or humanoid.Health <= 0 then
                billboardGui.Enabled = false
                highlight.Enabled = false
                return
            end

            billboardGui.Enabled = true
            highlight.Enabled = true

            -- Distance
            local hrp = LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
            local targetHrp = character:FindFirstChild("HumanoidRootPart")
            local distance = targetHrp and hrp and math.floor((hrp.Position - targetHrp.Position).Magnitude) or 0
            distanceLabel.Text = "Distance: " .. distance .. " studs"

            -- Health and Health Bar
            local health = math.floor(humanoid.Health)
            local maxHealth = humanoid.MaxHealth
            healthLabel.Text = "Health: " .. health .. "/" .. maxHealth
            local ratio = health / maxHealth
            healthBarFill.Size = UDim2.new(ratio, 0, 1, 0)

            if ratio > 0.6 then
                healthLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
                healthBarFill.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
            elseif ratio > 0.3 then
                healthLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
                healthBarFill.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
            else
                healthLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
                healthBarFill.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
            end
        end

        -- Connect updates
        local connection = RunService.Heartbeat:Connect(update)
        local healthConnection = humanoid.HealthChanged:Connect(update)
        local teamConnection = player:GetPropertyChangedSignal("Team"):Connect(update)

        -- Initial update to set visibility based on current team
        update()

        -- Cleanup on character removal
        character.AncestryChanged:Connect(function()
            if not character:IsDescendantOf(workspace) then
                connection:Disconnect()
                healthConnection:Disconnect()
                teamConnection:Disconnect()
                cleanupESP(player, character)
            end
        end)
    end

    -- Handle current character
    if player.Character then
        onCharacterAdded(player.Character)
    end
    player.CharacterAdded:Connect(onCharacterAdded)
end

-- Apply to existing players
for _, player in ipairs(Players:GetPlayers()) do
    createESP(player)
end

-- New players
Players.PlayerAdded:Connect(function(player)
    createESP(player)
end)

-- Remove on leave
Players.PlayerRemoving:Connect(function(player)
    cleanupESP(player, player.Character)
end)

-- Toggle ESP + Health Bar
UserInputService.InputBegan:Connect(function(input, processed)
    if processed then return end
    if input.KeyCode == Enum.KeyCode.Q then
        ESPEnabled = not ESPEnabled
        print("ESP + Health Bar Toggled:", ESPEnabled and "ON" or "OFF")
    end
end)

print("ESP + Health + Improved Health Bar + Team Check Loaded! Press Q to toggle.")

Features & Information

health bar ✅ chams ✅ tracers ❌ 2D Box❌ no need toggle

Community Comments (1)

NPCNOkNPCNOkOct 27, 2025

delta in big 25💔🥀

More Scripts for Universal Scripts