npc and player esp
Key RequiredUniversal

npc and player esp

Universal Scriptnothing_but_breadnothing_but_bread 1.1K views 366 executesUpdated Jan 15, 2026
Unrated
00
Lua Script•138 lines (4773 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local localPlayer = Players.LocalPlayer

-- State Tracking
local espEnabled = false
local connection 

-- Create the UI Elements
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "ESPGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = localPlayer:WaitForChild("PlayerGui")

-- Main Frame
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0, 150, 0, 50)
mainFrame.Position = UDim2.new(0, 10, 0.5, -25)
mainFrame.BackgroundTransparency = 1 
mainFrame.Parent = screenGui

local button = Instance.new("TextButton")
button.Size = UDim2.new(1, 0, 1, 0)
button.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
button.TextColor3 = Color3.fromRGB(255, 255, 255)
button.Text = "Activate ESP"
button.Font = Enum.Font.SourceSansBold
button.TextSize = 18
button.Parent = mainFrame

local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 8)
corner.Parent = button

-- Close Button (X)
local closeBtn = Instance.new("TextButton")
closeBtn.Size = UDim2.new(0, 20, 0, 20)
closeBtn.Position = UDim2.new(1, -10, 0, -10)
closeBtn.BackgroundColor3 = Color3.fromRGB(200, 0, 0)
closeBtn.Text = "X"
closeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
closeBtn.Font = Enum.Font.SourceSansBold
closeBtn.Parent = mainFrame

local closeCorner = Instance.new("UICorner")
closeCorner.CornerRadius = UDim.new(1, 0)
closeCorner.Parent = closeBtn

-- Drag Handle (Arrow)
local dragHandle = Instance.new("TextLabel")
dragHandle.Size = UDim2.new(0, 20, 0, 20)
dragHandle.Position = UDim2.new(0, -10, 0, -10)
dragHandle.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
dragHandle.Text = "⇱"
dragHandle.TextColor3 = Color3.fromRGB(255, 255, 255)
dragHandle.Font = Enum.Font.SourceSansBold
dragHandle.Active = true 
dragHandle.Parent = mainFrame

local dragCorner = Instance.new("UICorner")
dragCorner.CornerRadius = UDim.new(0, 4)
dragCorner.Parent = dragHandle

--- DRAG LOGIC ---
local dragging, dragStart, startPos
dragHandle.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        dragging = true
        dragStart = input.Position
        startPos = mainFrame.Position
        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then dragging = false end
        end)
    end
end)
UserInputService.InputChanged:Connect(function(input)
    if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
        local delta = input.Position - dragStart
        mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
    end
end)

--- COLOR LOGIC ---
local function applyHighlight(model)
    if not espEnabled then return end
    -- Check if it's a character (has a humanoid) and isn't the local player
    if model:IsA("Model") and model:FindFirstChildOfClass("Humanoid") and model ~= localPlayer.Character then
        if not model:FindFirstChild("TestHighlight") then
            local hl = Instance.new("Highlight")
            hl.Name = "TestHighlight"
            
            -- Check if model belongs to a Player
            local isPlayer = Players:GetPlayerFromCharacter(model)
            
            if isPlayer then
                hl.FillColor = Color3.fromRGB(0, 255, 0) -- Green for Players
            else
                hl.FillColor = Color3.fromRGB(255, 0, 0) -- Red for NPCs
            end
            
            hl.OutlineColor = Color3.fromRGB(255, 255, 255)
            hl.FillTransparency = 0.4
            hl.Parent = model
        end
    end
end

local function removeHighlights()
    for _, obj in pairs(workspace:GetDescendants()) do
        if obj:IsA("Highlight") and obj.Name == "TestHighlight" then
            obj:Destroy()
        end
    end
end

--- BUTTON LOGIC ---
button.MouseButton1Click:Connect(function()
    espEnabled = not espEnabled
    button.Text = espEnabled and "ESP: ON" or "ESP: OFF"
    button.BackgroundColor3 = espEnabled and Color3.fromRGB(0, 180, 0) or Color3.fromRGB(40, 40, 40)
    
    if espEnabled then
        for _, obj in pairs(workspace:GetDescendants()) do applyHighlight(obj) end
        connection = workspace.DescendantAdded:Connect(function(d)
            task.wait(0.1) -- Wait for humanoid to load
            applyHighlight(d)
        end)
    else
        if connection then connection:Disconnect() end
        removeHighlights()
    end
end)

closeBtn.MouseButton1Click:Connect(function()
    if connection then connection:Disconnect() end
    removeHighlights()
    screenGui:Destroy()
end)

Features & Information

it will highlight any npcs and players nearby it will also highlight parts from the game that is for some reason a player part

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts