Simple Player ESP
Key RequiredUniversal

Simple Player ESP

Universal ScriptInfiInfi 3.8K views 104 executesUpdated May 28, 2025
5.0/ 5(2 votes)
20100% Positive
Lua Script•413 lines (12109 chars)
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local MAIN_COLOR = Color3.fromRGB(28, 28, 28)
local SECONDARY_COLOR = Color3.fromRGB(40, 40, 40)
local ACCENT_COLOR = Color3.fromRGB(0, 170, 255)
local TEXT_COLOR = Color3.fromRGB(255, 255, 255)

local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "PlayerESP"
ScreenGui.Parent = PlayerGui

local Frame = Instance.new("Frame")
Frame.Size = UDim2.new(0, 300, 0, 180)
Frame.Position = UDim2.new(0.5, -150, 0, 10)
Frame.AnchorPoint = Vector2.new(0.5, 0)
Frame.BackgroundColor3 = MAIN_COLOR
Frame.BorderSizePixel = 0
Frame.ClipsDescendants = true
Frame.Parent = ScreenGui

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

local UIStroke = Instance.new("UIStroke")
UIStroke.Color = Color3.fromRGB(60, 60, 60)
UIStroke.Thickness = 2
UIStroke.Parent = Frame

local TitleBar = Instance.new("Frame")
TitleBar.Size = UDim2.new(1, 0, 0, 30)
TitleBar.BackgroundColor3 = SECONDARY_COLOR
TitleBar.BorderSizePixel = 0
TitleBar.Parent = Frame

local UICorner2 = Instance.new("UICorner")
UICorner2.CornerRadius = UDim.new(0, 8)
UICorner2.Parent = TitleBar

local Title = Instance.new("TextLabel")
Title.Text = "PLAYER ESP"
Title.Size = UDim2.new(1, -40, 1, 0)
Title.Position = UDim2.new(0, 10, 0, 0)
Title.BackgroundTransparency = 1
Title.TextColor3 = TEXT_COLOR
Title.Font = Enum.Font.GothamBold
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.Parent = TitleBar

local CloseButton = Instance.new("TextButton")
CloseButton.Text = "X"
CloseButton.Size = UDim2.new(0, 30, 1, 0)
CloseButton.Position = UDim2.new(1, -30, 0, 0)
CloseButton.BackgroundColor3 = SECONDARY_COLOR
CloseButton.TextColor3 = TEXT_COLOR
CloseButton.Font = Enum.Font.GothamBold
CloseButton.Parent = TitleBar

local dragging
local dragInput
local dragStart
local startPos

local function updateInput(input)
    local delta = input.Position - dragStart
    Frame.Position =
        UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end

TitleBar.InputBegan:Connect(
    function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = true
            dragStart = input.Position
            startPos = Frame.Position

            input.Changed:Connect(
                function()
                    if input.UserInputState == Enum.UserInputState.End then
                        dragging = false
                    end
                end
            )
        end
    end
)

TitleBar.InputChanged:Connect(
    function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement then
            dragInput = input
        end
    end
)

UserInputService.InputChanged:Connect(
    function(input)
        if input == dragInput and dragging then
            updateInput(input)
        end
    end
)

local SearchBox = Instance.new("TextBox")
SearchBox.PlaceholderText = "Search player..."
SearchBox.Size = UDim2.new(0.9, 0, 0, 35)
SearchBox.Position = UDim2.new(0.05, 0, 0, 40)
SearchBox.BackgroundColor3 = SECONDARY_COLOR
SearchBox.TextColor3 = TEXT_COLOR
SearchBox.ClearTextOnFocus = false
SearchBox.Font = Enum.Font.Gotham
SearchBox.TextSize = 14
SearchBox.Parent = Frame

local SearchBoxCorner = Instance.new("UICorner")
SearchBoxCorner.CornerRadius = UDim.new(0, 6)
SearchBoxCorner.Parent = SearchBox

local SuggestionsFrame = Instance.new("ScrollingFrame")
SuggestionsFrame.Size = UDim2.new(0.9, 0, 0, 120)
SuggestionsFrame.Position = UDim2.new(0.05, 0, 0, 80)
SuggestionsFrame.BackgroundColor3 = SECONDARY_COLOR
SuggestionsFrame.Visible = false
SuggestionsFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y
SuggestionsFrame.ScrollBarThickness = 4
SuggestionsFrame.ScrollBarImageColor3 = ACCENT_COLOR
SuggestionsFrame.Parent = Frame

local SuggestionsCorner = Instance.new("UICorner")
SuggestionsCorner.CornerRadius = UDim.new(0, 6)
SuggestionsCorner.Parent = SuggestionsFrame

local UIListLayout = Instance.new("UIListLayout")
UIListLayout.Padding = UDim.new(0, 5)
UIListLayout.Parent = SuggestionsFrame

local ToggleButton = Instance.new("TextButton")
ToggleButton.Text = "TOGGLE ESP"
ToggleButton.Size = UDim2.new(0.9, 0, 0, 35)
ToggleButton.Position = UDim2.new(0.05, 0, 0, 140)
ToggleButton.BackgroundColor3 = ACCENT_COLOR
ToggleButton.TextColor3 = TEXT_COLOR
ToggleButton.Font = Enum.Font.GothamBold
ToggleButton.TextSize = 14
ToggleButton.Parent = Frame

local ToggleButtonCorner = Instance.new("UICorner")
ToggleButtonCorner.CornerRadius = UDim.new(0, 6)
ToggleButtonCorner.Parent = ToggleButton

local ESP = {
    Enabled = false,
    Players = {},
    Boxes = {},
    HealthBars = {},
    Names = {},
    Tracers = false
}

function ESP:Add(player)
    if self.Players[player] then
        return
    end

    local character = player.Character
    if not character then
        player.CharacterAdded:Wait()
        character = player.Character
    end

    local humanoid = character:WaitForChild("Humanoid")

    local box = Instance.new("BoxHandleAdornment")
    box.Name = "ESP_Box"
    box.Adornee = character
    box.AlwaysOnTop = true
    box.ZIndex = 10
    box.Size = character:GetExtentsSize() * 1.1
    box.Transparency = 0.7
    box.Color3 = player.TeamColor.Color
    box.Parent = character

    local healthBar = Instance.new("BillboardGui")
    healthBar.Name = "ESP_HealthBar"
    healthBar.Adornee = character
    healthBar.AlwaysOnTop = true
    healthBar.Size = UDim2.new(2, 0, 0.2, 0)
    healthBar.StudsOffset = Vector3.new(0, character:GetExtentsSize().Y / 2 + 0.5, 0)
    healthBar.Parent = character

    local barFrame = Instance.new("Frame")
    barFrame.BackgroundColor3 = Color3.new(0, 0, 0)
    barFrame.BorderSizePixel = 1
    barFrame.BorderColor3 = Color3.new(1, 1, 1)
    barFrame.Size = UDim2.new(1, 0, 1, 0)
    barFrame.Parent = healthBar

    local healthFill = Instance.new("Frame")
    healthFill.BackgroundColor3 = Color3.new(0, 1, 0)
    healthFill.BorderSizePixel = 0
    healthFill.Size = UDim2.new(humanoid.Health / humanoid.MaxHealth, 0, 1, 0)
    healthFill.Parent = barFrame

    local nameLabel = Instance.new("BillboardGui")
    nameLabel.Name = "ESP_Name"
    nameLabel.Adornee = character
    nameLabel.AlwaysOnTop = true
    nameLabel.Size = UDim2.new(0, 200, 0, 50)
    nameLabel.StudsOffset = Vector3.new(0, character:GetExtentsSize().Y / 2 + 1.5, 0)
    nameLabel.Parent = character

    local nameText = Instance.new("TextLabel")
    nameText.BackgroundTransparency = 1
    nameText.Text = player.Name
    nameText.TextColor3 = player.TeamColor.Color
    nameText.TextStrokeTransparency = 0
    nameText.TextSize = 14
    nameText.Font = Enum.Font.GothamBold
    nameText.Size = UDim2.new(1, 0, 1, 0)
    nameText.Parent = nameLabel

    self.Players[player] = true
    self.Boxes[player] = box
    self.HealthBars[player] = {
        gui = healthBar,
        fill = healthFill,
        humanoid = humanoid
    }
    self.Names[player] = nameLabel

    humanoid.HealthChanged:Connect(
        function()
            if humanoid.Health <= 0 then
                healthFill.Size = UDim2.new(0, 0, 1, 0)
            else
                healthFill.Size = UDim2.new(humanoid.Health / humanoid.MaxHealth, 0, 1, 0)
                healthFill.BackgroundColor3 =
                    Color3.new(1 - (humanoid.Health / humanoid.MaxHealth), humanoid.Health / humanoid.MaxHealth, 0)
            end
        end
    )

    character.AncestryChanged:Connect(
        function(_, parent)
            if not parent then
                self:Remove(player)
            end
        end
    )

    player.CharacterAdded:Connect(
        function(newChar)
            self:Remove(player)
            wait()
            self:Add(player)
        end
    )
end

function ESP:Remove(player)
    if self.Boxes[player] then
        self.Boxes[player]:Destroy()
        self.Boxes[player] = nil
    end
    if self.HealthBars[player] then
        self.HealthBars[player].gui:Destroy()
        self.HealthBars[player] = nil
    end
    if self.Names[player] then
        self.Names[player]:Destroy()
        self.Names[player] = nil
    end
    self.Players[player] = nil
end

function ESP:TogglePlayer(player, state)
    if state then
        self:Add(player)
    else
        self:Remove(player)
    end
end

local selectedPlayer = nil

local function updateSuggestions(searchText)
    SuggestionsFrame:ClearAllChildren()

    if searchText == "" then
        SuggestionsFrame.Visible = false
        return
    end

    local foundAny = false

    for _, player in ipairs(Players:GetPlayers()) do
        if player ~= LocalPlayer and string.find(string.lower(player.Name), string.lower(searchText)) then
            local suggestionButton = Instance.new("TextButton")
            suggestionButton.Text = player.Name
            suggestionButton.Size = UDim2.new(1, -10, 0, 30)
            suggestionButton.Position = UDim2.new(0, 5, 0, 0)
            suggestionButton.BackgroundColor3 = MAIN_COLOR
            suggestionButton.TextColor3 = TEXT_COLOR
            suggestionButton.Font = Enum.Font.Gotham
            suggestionButton.TextSize = 14
            suggestionButton.AutoButtonColor = false
            suggestionButton.Parent = SuggestionsFrame

            local buttonCorner = Instance.new("UICorner")
            buttonCorner.CornerRadius = UDim.new(0, 4)
            buttonCorner.Parent = suggestionButton

            suggestionButton.MouseEnter:Connect(
                function()
                    suggestionButton.BackgroundColor3 = SECONDARY_COLOR
                end
            )

            suggestionButton.MouseLeave:Connect(
                function()
                    suggestionButton.BackgroundColor3 = MAIN_COLOR
                end
            )

            suggestionButton.MouseButton1Click:Connect(
                function()
                    SearchBox.Text = player.Name
                    selectedPlayer = player
                    SuggestionsFrame.Visible = false
                end
            )

            foundAny = true
        end
    end

    SuggestionsFrame.Visible = foundAny
end

SearchBox:GetPropertyChangedSignal("Text"):Connect(
    function()
        updateSuggestions(SearchBox.Text)
    end
)

SearchBox.Focused:Connect(
    function()
        updateSuggestions(SearchBox.Text)
    end
)

SearchBox.FocusLost:Connect(
    function()
        wait(0.1)
        SuggestionsFrame.Visible = false
    end
)

ToggleButton.MouseButton1Click:Connect(
    function()
        if selectedPlayer then
            ESP:TogglePlayer(selectedPlayer, not ESP.Players[selectedPlayer])
            ToggleButton.BackgroundColor3 = ESP.Players[selectedPlayer] and Color3.fromRGB(255, 50, 50) or ACCENT_COLOR
            ToggleButton.Text = ESP.Players[selectedPlayer] and "ESP ACTIVE" or "TOGGLE ESP"
        end
    end
)

CloseButton.MouseButton1Click:Connect(
    function()
        ScreenGui:Destroy()
    end
)

Players.PlayerRemoving:Connect(
    function(player)
        ESP:Remove(player)
        if selectedPlayer == player then
            selectedPlayer = nil
            SearchBox.Text = ""
            ToggleButton.BackgroundColor3 = ACCENT_COLOR
            ToggleButton.Text = "TOGGLE ESP"
        end
    end
)

for _, player in ipairs(Players:GetPlayers()) do
    if player ~= LocalPlayer then
        player.CharacterAdded:Connect(
            function(character)
                if selectedPlayer == player and ESP.Players[player] then
                    ESP:Add(player)
                end
            end
        )
    end
end

Players.PlayerAdded:Connect(
    function(player)
        player.CharacterAdded:Connect(
            function(character)
                if selectedPlayer == player and ESP.Players[player] then
                    ESP:Add(player)
                end
            end
        )
    end
)

Features & Information

Just an ESP gui

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts