esp by ai OPEN SOURCE
Key RequiredUniversal

esp by ai OPEN SOURCE

Universal ScriptZxcrosticZxcrostic 273 views 14 executesUpdated Feb 3, 2026
Unrated
00
Lua Script•1637 lines (64495 chars)
--[[
╔════════════════════════════════════════════════════════════════════════════════╗
║                                                                                ║
║        ██╗ ██████╗██╗  ██╗███████╗ █████╗ ████████╗███████╗                   ║
║        ██║██╔════╝██║  ██║██╔════╝██╔══██╗╚══██╔══╝██╔════╝                   ║
║        ██║██║     ███████║█████╗  ███████║   ██║   ███████╗                   ║
║   ██   ██║██║     ██╔══██║██╔══╝  ██╔══██║   ██║   ╚════██║                   ║
║   ╚█████╔╝╚██████╗██║  ██║███████╗██║  ██║   ██║   ███████║                   ║
║    ╚════╝  ╚═════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝   ╚═╝   ╚══════╝                   ║
║                                                                                ║
║                    M A S T E R P I E C E   E S P                               ║
║                      Full Package: ESP + Menu                                   ║
║                                                                                ║
║                         by Bin for Jack ♡                                      ║
║                                                                                ║
╚════════════════════════════════════════════════════════════════════════════════╝
]]

-- ════════════════════════════════════════════════════════════════════════════════
-- SERVICES
-- ════════════════════════════════════════════════════════════════════════════════

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

local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local Mouse = LocalPlayer:GetMouse()

-- ════════════════════════════════════════════════════════════════════════════════
-- CONFIGURATION
-- ════════════════════════════════════════════════════════════════════════════════

local Config = {
    -- Main
    Enabled = true,
    TeamCheck = false,
    MaxDistance = 2500,
    
    -- Box
    Box = true,
    DynamicBox = true,
    BoxPadding = 4,
    BoxGlow = true,
    BoxGlowIntensity = 55,
    BoxFill = true,
    BoxFillOpacity = 92,
    BoxGradient = true,
    BoxCornerLength = 28,
    BoxAnimated = true,
    BoxAccentLines = true,
    BoxCornerDots = true,
    
    -- Name
    Name = true,
    NameGlow = true,
    NameBackground = true,
    NameSize = 13,
    
    -- Health
    Health = true,
    HealthSegments = 10,
    HealthGlow = true,
    HealthText = true,
    
    -- Distance
    Distance = true,
    
    -- Weapon
    Weapon = true,
    WeaponBackground = true,
    
    -- Tracer
    Tracer = true,
    TracerOrigin = "Bottom",
    TracerGlow = true,
    TracerSegments = 16,
    
    -- Skeleton
    Skeleton = true,
    SkeletonGlow = true,
    SkeletonThickness = 16,
    
    -- Head
    HeadDot = true,
    HeadDotSize = 4,
    
    -- Look Direction
    LookDirection = true,
    LookLength = 40,
    
    -- Off-Screen
    OffScreenArrows = true,
    ArrowSize = 20,
    ArrowDistance = 140,
    
    -- Chams
    Chams = true,
    ChamsOpacity = 35,
    
    -- UI
    Crosshair = true,
    Watermark = true,
    TargetInfo = true,
    FPSCounter = true,
    GlowPulse = true,
    SmoothMovement = true,
    AnimationSpeed = 50,
    
    -- Colors
    EnemyColor = Color3.fromRGB(255, 85, 100),
    EnemyColorLight = Color3.fromRGB(255, 140, 150),
    TeamColor = Color3.fromRGB(85, 255, 170),
    TeamColorLight = Color3.fromRGB(140, 255, 200)
}

-- ════════════════════════════════════════════════════════════════════════════════
-- UTILITY FUNCTIONS
-- ════════════════════════════════════════════════════════════════════════════════

local floor, ceil, clamp, sin, cos, tan, atan2, rad, deg, abs, min, max, sqrt, pi, huge =
    math.floor, math.ceil, math.clamp, math.sin, math.cos, math.tan, math.atan2,
    math.rad, math.deg, math.abs, math.min, math.max, math.sqrt, math.pi, math.huge

local function Lerp(a, b, t)
    return a + (b - a) * t
end

local function LerpColor(c1, c2, t)
    return Color3.new(Lerp(c1.R, c2.R, t), Lerp(c1.G, c2.G, t), Lerp(c1.B, c2.B, t))
end

local function LerpVector2(v1, v2, t)
    return Vector2.new(Lerp(v1.X, v2.X, t), Lerp(v1.Y, v2.Y, t))
end

local function SmoothStep(t)
    return t * t * (3 - 2 * t)
end

local function GetPulse(speed, minVal, maxVal)
    local t = (sin(tick() * speed * pi) + 1) / 2
    return Lerp(minVal or 0, maxVal or 1, t)
end

local function GetBreathing(speed, minVal, maxVal)
    local t = (sin(tick() * speed) + 1) / 2
    t = SmoothStep(t)
    return Lerp(minVal or 0, maxVal or 1, t)
end

local function GetHealthColor(percent)
    percent = clamp(percent, 0, 1)
    if percent > 0.6 then
        return LerpColor(Color3.fromRGB(255, 200, 0), Color3.fromRGB(80, 255, 120), (percent - 0.6) / 0.4)
    elseif percent > 0.3 then
        return LerpColor(Color3.fromRGB(255, 100, 50), Color3.fromRGB(255, 200, 0), (percent - 0.3) / 0.3)
    else
        return LerpColor(Color3.fromRGB(255, 50, 50), Color3.fromRGB(255, 100, 50), percent / 0.3)
    end
end

local function WorldToScreen(pos)
    local screenPos, onScreen = Camera:WorldToViewportPoint(pos)
    return Vector2.new(screenPos.X, screenPos.Y), onScreen, screenPos.Z
end

local function IsAlive(player)
    local char = player.Character
    if not char then return false end
    local hum = char:FindFirstChildOfClass("Humanoid")
    local root = char:FindFirstChild("HumanoidRootPart")
    return hum and root and hum.Health > 0
end

local function IsTeammate(player)
    if not Config.TeamCheck then return false end
    return player.Team and LocalPlayer.Team and player.Team == LocalPlayer.Team
end

local function GetDistance(p1, p2)
    return (p1 - p2).Magnitude
end

-- ════════════════════════════════════════════════════════════════════════════════
-- DYNAMIC BOUNDING BOX
-- ════════════════════════════════════════════════════════════════════════════════

local function GetDynamicBoundingBox(character)
    local minX, minY = huge, huge
    local maxX, maxY = -huge, -huge
    local onScreenCount = 0
    local totalDepth = 0
    
    local parts = {
        "Head", "UpperTorso", "LowerTorso", "Torso", "HumanoidRootPart",
        "LeftUpperArm", "LeftLowerArm", "LeftHand",
        "RightUpperArm", "RightLowerArm", "RightHand",
        "LeftUpperLeg", "LeftLowerLeg", "LeftFoot",
        "RightUpperLeg", "RightLowerLeg", "RightFoot",
        "Left Arm", "Right Arm", "Left Leg", "Right Leg"
    }
    
    for _, partName in ipairs(parts) do
        local part = character:FindFirstChild(partName)
        if part and part:IsA("BasePart") then
            local cf = part.CFrame
            local size = part.Size
            
            local corners = {
                cf * CFrame.new( size.X/2,  size.Y/2,  size.Z/2),
                cf * CFrame.new( size.X/2,  size.Y/2, -size.Z/2),
                cf * CFrame.new( size.X/2, -size.Y/2,  size.Z/2),
                cf * CFrame.new( size.X/2, -size.Y/2, -size.Z/2),
                cf * CFrame.new(-size.X/2,  size.Y/2,  size.Z/2),
                cf * CFrame.new(-size.X/2,  size.Y/2, -size.Z/2),
                cf * CFrame.new(-size.X/2, -size.Y/2,  size.Z/2),
                cf * CFrame.new(-size.X/2, -size.Y/2, -size.Z/2)
            }
            
            for _, corner in ipairs(corners) do
                local screenPos, onScreen, depth = WorldToScreen(corner.Position)
                if onScreen and depth > 0 then
                    minX = min(minX, screenPos.X)
                    minY = min(minY, screenPos.Y)
                    maxX = max(maxX, screenPos.X)
                    maxY = max(maxY, screenPos.Y)
                    onScreenCount = onScreenCount + 1
                    totalDepth = totalDepth + depth
                end
            end
        end
    end
    
    if onScreenCount < 4 then return nil end
    
    local padding = Config.BoxPadding
    minX, minY = minX - padding, minY - padding
    maxX, maxY = maxX + padding, maxY + padding
    
    return {
        Position = Vector2.new((minX + maxX) / 2, (minY + maxY) / 2),
        Size = Vector2.new(maxX - minX, maxY - minY),
        Min = Vector2.new(minX, minY),
        Max = Vector2.new(maxX, maxY),
        Depth = totalDepth / onScreenCount
    }
end

local function GetSimpleBoundingBox(character)
    local root = character:FindFirstChild("HumanoidRootPart")
    if not root then return nil end
    
    local pos, onScreen, depth = WorldToScreen(root.Position)
    if not onScreen or depth < 0 then return nil end
    
    local scale = 1 / (depth * tan(rad(Camera.FieldOfView / 2)) * 2) * 1000
    local height = scale * 5.2
    local width = height * 0.5
    
    return {
        Position = pos,
        Size = Vector2.new(width, height),
        Min = Vector2.new(pos.X - width/2, pos.Y - height/2),
        Max = Vector2.new(pos.X + width/2, pos.Y + height/2),
        Depth = depth
    }
end

local function GetBoundingBox(character)
    if Config.DynamicBox then
        local dynamic = GetDynamicBoundingBox(character)
        if dynamic then return dynamic end
    end
    return GetSimpleBoundingBox(character)
end

-- ════════════════════════════════════════════════════════════════════════════════
-- DRAWING UTILITIES
-- ════════════════════════════════════════════════════════════════════════════════

local function NewDrawing(drawingType, props)
    local d = Drawing.new(drawingType)
    for k, v in pairs(props or {}) do
        pcall(function() d[k] = v end)
    end
    return d
end

-- ════════════════════════════════════════════════════════════════════════════════
-- ESP CACHE & OBJECTS
-- ════════════════════════════════════════════════════════════════════════════════

local ESPObjects = {}
local SmoothData = {}

local function CreateESP(player)
    local esp = {
        -- Box
        BoxFill = NewDrawing("Square", { Filled = true }),
        BoxFillGradient = NewDrawing("Square", { Filled = true }),
        BoxGlowOuter = {},
        BoxGlowInner = {},
        BoxOutlines = {},
        BoxCorners = {},
        BoxAccentLines = {},
        BoxCornerDots = {},
        BoxCornerDotsGlow = {},
        
        -- Name
        NameBackground = NewDrawing("Square", { Filled = true }),
        NameGlow = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex }),
        NameShadow = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex, Color = Color3.new(0,0,0) }),
        Name = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex }),
        
        -- Distance
        DistanceShadow = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex, Color = Color3.new(0,0,0) }),
        Distance = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex }),
        
        -- Weapon
        WeaponBackground = NewDrawing("Square", { Filled = true }),
        WeaponShadow = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex, Color = Color3.new(0,0,0) }),
        Weapon = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex }),
        
        -- Health
        HealthOutline = NewDrawing("Square", { Filled = true, Color = Color3.new(0,0,0) }),
        HealthBackground = NewDrawing("Square", { Filled = true }),
        HealthGlow = NewDrawing("Square", { Filled = true }),
        HealthSegments = {},
        HealthText = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex, Outline = true }),
        
        -- Tracer
        TracerGlows = {},
        TracerLines = {},
        
        -- Skeleton
        SkeletonGlows = {},
        SkeletonBones = {},
        SkeletonJoints = {},
        
        -- Head
        HeadGlowOuter = NewDrawing("Circle", { Filled = true, NumSides = 24 }),
        HeadGlowInner = NewDrawing("Circle", { Filled = true, NumSides = 24 }),
        HeadOutline = NewDrawing("Circle", { Filled = true, NumSides = 24, Color = Color3.new(0,0,0) }),
        HeadDot = NewDrawing("Circle", { Filled = true, NumSides = 24 }),
        
        -- Look Direction
        LookGlow = NewDrawing("Line", {}),
        LookLine = NewDrawing("Line", {}),
        LookArrow = NewDrawing("Triangle", { Filled = true }),
        
        -- Off-Screen Arrow
        ArrowGlowOuter = NewDrawing("Triangle", { Filled = true }),
        ArrowGlowInner = NewDrawing("Triangle", { Filled = true }),
        ArrowOutline = NewDrawing("Triangle", { Filled = true, Color = Color3.new(0,0,0) }),
        Arrow = NewDrawing("Triangle", { Filled = true }),
        ArrowDistance = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex, Outline = true }),
        ArrowName = NewDrawing("Text", { Center = true, Font = Drawing.Fonts.Plex, Outline = true }),
        
        -- Chams
        Highlight = Instance.new("Highlight")
    }
    
    -- Initialize arrays
    for i = 1, 8 do
        esp.BoxGlowOuter[i] = NewDrawing("Line", { Thickness = 6 })
        esp.BoxGlowInner[i] = NewDrawing("Line", { Thickness = 3 })
        esp.BoxOutlines[i] = NewDrawing("Line", { Thickness = 3, Color = Color3.new(0,0,0) })
        esp.BoxCorners[i] = NewDrawing("Line", { Thickness = 1.5 })
    end
    
    for i = 1, 4 do
        esp.BoxAccentLines[i] = NewDrawing("Line", { Thickness = 1 })
        esp.BoxCornerDots[i] = NewDrawing("Circle", { Filled = true, NumSides = 12, Radius = 2.5 })
        esp.BoxCornerDotsGlow[i] = NewDrawing("Circle", { Filled = true, NumSides = 12 })
    end
    
    for i = 1, Config.HealthSegments do
        esp.HealthSegments[i] = NewDrawing("Square", { Filled = true })
    end
    
    for i = 1, Config.TracerSegments do
        esp.TracerGlows[i] = NewDrawing("Line", { Thickness = 4 })
        esp.TracerLines[i] = NewDrawing("Line", { Thickness = 1.2 })
    end
    
    for i = 1, 14 do
        esp.SkeletonGlows[i] = NewDrawing("Line", { Thickness = 4 })
        esp.SkeletonBones[i] = NewDrawing("Line", { Thickness = 1.5 })
    end
    
    for i = 1, 16 do
        esp.SkeletonJoints[i] = NewDrawing("Circle", { Filled = true, NumSides = 10, Radius = 2 })
    end
    
    esp.Highlight.FillTransparency = Config.ChamsOpacity / 100
    esp.Highlight.OutlineTransparency = 0
    esp.Highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
    
    return esp
end

local function DestroyESP(player)
    local esp = ESPObjects[player]
    if not esp then return end
    
    local function remove(d)
        if d and type(d) == "table" and d.Remove then
            pcall(function() d:Remove() end)
        end
    end
    
    for k, v in pairs(esp) do
        if type(v) == "table" and v[1] then
            for _, d in pairs(v) do remove(d) end
        elseif typeof(v) == "Instance" then
            pcall(function() v:Destroy() end)
        else
            remove(v)
        end
    end
    
    ESPObjects[player] = nil
    SmoothData[player] = nil
end

-- ════════════════════════════════════════════════════════════════════════════════
-- ESP UPDATE FUNCTION
-- ════════════════════════════════════════════════════════════════════════════════

local function UpdateESP(player, esp)
    local character = player.Character
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    local root = character and character:FindFirstChild("HumanoidRootPart")
    local head = character and character:FindFirstChild("Head")
    
    if not SmoothData[player] then
        SmoothData[player] = { boxMin = nil, boxMax = nil, health = 1, lastUpdate = tick() }
    end
    local smooth = SmoothData[player]
    local deltaTime = tick() - smooth.lastUpdate
    smooth.lastUpdate = tick()
    
    -- Hide all function
    local function HideAll()
        esp.BoxFill.Visible = false
        esp.BoxFillGradient.Visible = false
        for i = 1, 8 do
            esp.BoxGlowOuter[i].Visible = false
            esp.BoxGlowInner[i].Visible = false
            esp.BoxOutlines[i].Visible = false
            esp.BoxCorners[i].Visible = false
        end
        for i = 1, 4 do
            esp.BoxAccentLines[i].Visible = false
            esp.BoxCornerDots[i].Visible = false
            esp.BoxCornerDotsGlow[i].Visible = false
        end
        esp.NameBackground.Visible = false
        esp.NameGlow.Visible = false
        esp.NameShadow.Visible = false
        esp.Name.Visible = false
        esp.DistanceShadow.Visible = false
        esp.Distance.Visible = false
        esp.WeaponBackground.Visible = false
        esp.WeaponShadow.Visible = false
        esp.Weapon.Visible = false
        esp.HealthOutline.Visible = false
        esp.HealthBackground.Visible = false
        esp.HealthGlow.Visible = false
        esp.HealthText.Visible = false
        for i = 1, #esp.HealthSegments do esp.HealthSegments[i].Visible = false end
        for i = 1, #esp.TracerGlows do
            esp.TracerGlows[i].Visible = false
            esp.TracerLines[i].Visible = false
        end
        for i = 1, #esp.SkeletonGlows do
            esp.SkeletonGlows[i].Visible = false
            esp.SkeletonBones[i].Visible = false
        end
        for i = 1, #esp.SkeletonJoints do esp.SkeletonJoints[i].Visible = false end
        esp.HeadGlowOuter.Visible = false
        esp.HeadGlowInner.Visible = false
        esp.HeadOutline.Visible = false
        esp.HeadDot.Visible = false
        esp.LookGlow.Visible = false
        esp.LookLine.Visible = false
        esp.LookArrow.Visible = false
        esp.ArrowGlowOuter.Visible = false
        esp.ArrowGlowInner.Visible = false
        esp.ArrowOutline.Visible = false
        esp.Arrow.Visible = false
        esp.ArrowDistance.Visible = false
        esp.ArrowName.Visible = false
        if esp.Highlight.Parent then esp.Highlight.Parent = nil end
    end
    
    if not Config.Enabled or not IsAlive(player) then
        HideAll()
        return
    end
    
    local localRoot = LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
    if not localRoot then HideAll() return end
    
    local distance = GetDistance(root.Position, localRoot.Position)
    if distance > Config.MaxDistance then HideAll() return end
    
    local isTeammate = IsTeammate(player)
    local mainColor = isTeammate and Config.TeamColor or Config.EnemyColor
    local lightColor = isTeammate and Config.TeamColorLight or Config.EnemyColorLight
    
    local time = tick()
    local pulse = Config.GlowPulse and GetPulse(3 * (Config.AnimationSpeed / 50), 0.5, 0.8) or (Config.BoxGlowIntensity / 100)
    local breathe = GetBreathing(2 * (Config.AnimationSpeed / 50), 0.9, 1.1)
    
    local bbox = GetBoundingBox(character)
    
    -- ═══ OFF-SCREEN ARROWS ═══
    if not bbox and Config.OffScreenArrows then
        local pos, onScreen = WorldToScreen(root.Position)
        if not onScreen then
            local center = Camera.ViewportSize / 2
            local dir = (pos - center).Unit
            local arrowPos = center + dir * Config.ArrowDistance
            
            local angle = atan2(dir.Y, dir.X)
            local size = Config.ArrowSize * breathe
            
            local p1 = arrowPos + Vector2.new(cos(angle) * size, sin(angle) * size)
            local p2 = arrowPos + Vector2.new(cos(angle + 2.3) * size * 0.55, sin(angle + 2.3) * size * 0.55)
            local p3 = arrowPos + Vector2.new(cos(angle - 2.3) * size * 0.55, sin(angle - 2.3) * size * 0.55)
            
            if Config.BoxGlow then
                esp.ArrowGlowOuter.PointA, esp.ArrowGlowOuter.PointB, esp.ArrowGlowOuter.PointC = p1, p2, p3
                esp.ArrowGlowOuter.Color = mainColor
                esp.ArrowGlowOuter.Transparency = pulse + 0.3
                esp.ArrowGlowOuter.Visible = true
                
                esp.ArrowGlowInner.PointA, esp.ArrowGlowInner.PointB, esp.ArrowGlowInner.PointC = p1, p2, p3
                esp.ArrowGlowInner.Color = lightColor
                esp.ArrowGlowInner.Transparency = pulse
                esp.ArrowGlowInner.Visible = true
            else
                esp.ArrowGlowOuter.Visible = false
                esp.ArrowGlowInner.Visible = false
            end
            
            local outDir = dir * 2
            esp.ArrowOutline.PointA = p1 + outDir
            esp.ArrowOutline.PointB = p2 + outDir
            esp.ArrowOutline.PointC = p3 + outDir
            esp.ArrowOutline.Visible = true
            
            esp.Arrow.PointA, esp.Arrow.PointB, esp.Arrow.PointC = p1, p2, p3
            esp.Arrow.Color = mainColor
            esp.Arrow.Visible = true
            
            esp.ArrowDistance.Text = floor(distance) .. "m"
            esp.ArrowDistance.Position = arrowPos - dir * 25
            esp.ArrowDistance.Color = Color3.fromRGB(200, 200, 210)
            esp.ArrowDistance.Visible = true
            
            esp.ArrowName.Text = player.DisplayName
            esp.ArrowName.Position = arrowPos - dir * 38
            esp.ArrowName.Color = mainColor
            esp.ArrowName.Visible = true
        else
            esp.ArrowGlowOuter.Visible = false
            esp.ArrowGlowInner.Visible = false
            esp.ArrowOutline.Visible = false
            esp.Arrow.Visible = false
            esp.ArrowDistance.Visible = false
            esp.ArrowName.Visible = false
        end
    else
        esp.ArrowGlowOuter.Visible = false
        esp.ArrowGlowInner.Visible = false
        esp.ArrowOutline.Visible = false
        esp.Arrow.Visible = false
        esp.ArrowDistance.Visible = false
        esp.ArrowName.Visible = false
    end
    
    if not bbox then HideAll() return end
    
    -- Smooth movement
    local left, top, right, bottom
    if Config.SmoothMovement and smooth.boxMin then
        local smoothFactor = clamp(deltaTime * 15, 0, 1)
        smooth.boxMin = LerpVector2(smooth.boxMin, bbox.Min, smoothFactor)
        smooth.boxMax = LerpVector2(smooth.boxMax, bbox.Max, smoothFactor)
        left, top = smooth.boxMin.X, smooth.boxMin.Y
        right, bottom = smooth.boxMax.X, smooth.boxMax.Y
    else
        smooth.boxMin = bbox.Min
        smooth.boxMax = bbox.Max
        left, top = bbox.Min.X, bbox.Min.Y
        right, bottom = bbox.Max.X, bbox.Max.Y
    end
    
    local width = right - left
    local height = bottom - top
    local centerX = (left + right) / 2
    local centerY = (top + bottom) / 2
    local cornerLen = min(width, height) * (Config.BoxCornerLength / 100)
    
    -- ═══ BOX ═══
    if Config.Box then
        if Config.BoxFill then
            esp.BoxFill.Position = Vector2.new(left, top)
            esp.BoxFill.Size = Vector2.new(width, height)
            esp.BoxFill.Color = mainColor
            esp.BoxFill.Transparency = Config.BoxFillOpacity / 100
            esp.BoxFill.Visible = true
            
            if Config.BoxGradient then
                esp.BoxFillGradient.Position = Vector2.new(left, top)
                esp.BoxFillGradient.Size = Vector2.new(width, height * 0.35)
                esp.BoxFillGradient.Color = lightColor
                esp.BoxFillGradient.Transparency = (Config.BoxFillOpacity / 100) + 0.03
                esp.BoxFillGradient.Visible = true
            else
                esp.BoxFillGradient.Visible = false
            end
        else
            esp.BoxFill.Visible = false
            esp.BoxFillGradient.Visible = false
        end
        
        local corners = {
            {Vector2.new(left, top), Vector2.new(left + cornerLen, top)},
            {Vector2.new(left, top), Vector2.new(left, top + cornerLen)},
            {Vector2.new(right, top), Vector2.new(right - cornerLen, top)},
            {Vector2.new(right, top), Vector2.new(right, top + cornerLen)},
            {Vector2.new(left, bottom), Vector2.new(left + cornerLen, bottom)},
            {Vector2.new(left, bottom), Vector2.new(left, bottom - cornerLen)},
            {Vector2.new(right, bottom), Vector2.new(right - cornerLen, bottom)},
            {Vector2.new(right, bottom), Vector2.new(right, bottom - cornerLen)}
        }
        
        for i, corner in ipairs(corners) do
            local from, to = corner[1], corner[2]
            local isTop = (i <= 4)
            local cornerColor = isTop and LerpColor(mainColor, lightColor, 0.3) or mainColor
            
            if Config.BoxGlow then
                esp.BoxGlowOuter[i].From = from
                esp.BoxGlowOuter[i].To = to
                esp.BoxGlowOuter[i].Color = mainColor
                esp.BoxGlowOuter[i].Transparency = pulse + 0.3
                esp.BoxGlowOuter[i].Visible = true
                
                esp.BoxGlowInner[i].From = from
                esp.BoxGlowInner[i].To = to
                esp.BoxGlowInner[i].Color = lightColor
                esp.BoxGlowInner[i].Transparency = pulse
                esp.BoxGlowInner[i].Visible = true
            else
                esp.BoxGlowOuter[i].Visible = false
                esp.BoxGlowInner[i].Visible = false
            end
            
            esp.BoxOutlines[i].From = from
            esp.BoxOutlines[i].To = to
            esp.BoxOutlines[i].Visible = true
            
            esp.BoxCorners[i].From = from
            esp.BoxCorners[i].To = to
            esp.BoxCorners[i].Color = cornerColor
            esp.BoxCorners[i].Visible = true
        end
        
        if Config.BoxAccentLines then
            local accents = {
                {Vector2.new(left + cornerLen + 3, top), Vector2.new(right - cornerLen - 3, top)},
                {Vector2.new(left + cornerLen + 3, bottom), Vector2.new(right - cornerLen - 3, bottom)},
                {Vector2.new(left, top + cornerLen + 3), Vector2.new(left, bottom - cornerLen - 3)},
                {Vector2.new(right, top + cornerLen + 3), Vector2.new(right, bottom - cornerLen - 3)}
            }
            for i, acc in ipairs(accents) do
                esp.BoxAccentLines[i].From = acc[1]
                esp.BoxAccentLines[i].To = acc[2]
                esp.BoxAccentLines[i].Color = mainColor
                esp.BoxAccentLines[i].Transparency = 0.6
                esp.BoxAccentLines[i].Visible = true
            end
        else
            for i = 1, 4 do esp.BoxAccentLines[i].Visible = false end
        end
        
        if Config.BoxCornerDots then
            local dots = {Vector2.new(left, top), Vector2.new(right, top), Vector2.new(left, bottom), Vector2.new(right, bottom)}
            local dotPulse = GetBreathing(3, 2, 3.5)
            for i, pos in ipairs(dots) do
                if Config.BoxGlow then
                    esp.BoxCornerDotsGlow[i].Position = pos
                    esp.BoxCornerDotsGlow[i].Radius = dotPulse + 2
                    esp.BoxCornerDotsGlow[i].Color = mainColor
                    esp.BoxCornerDotsGlow[i].Transparency = pulse
                    esp.BoxCornerDotsGlow[i].Visible = true
                else
                    esp.BoxCornerDotsGlow[i].Visible = false
                end
                esp.BoxCornerDots[i].Position = pos
                esp.BoxCornerDots[i].Color = lightColor
                esp.BoxCornerDots[i].Visible = true
            end
        else
            for i = 1, 4 do
                esp.BoxCornerDots[i].Visible = false
                esp.BoxCornerDotsGlow[i].Visible = false
            end
        end
    else
        esp.BoxFill.Visible = false
        esp.BoxFillGradient.Visible = false
        for i = 1, 8 do
            esp.BoxGlowOuter[i].Visible = false
            esp.BoxGlowInner[i].Visible = false
            esp.BoxOutlines[i].Visible = false
            esp.BoxCorners[i].Visible = false
        end
        for i = 1, 4 do
            esp.BoxAccentLines[i].Visible = false
            esp.BoxCornerDots[i].Visible = false
            esp.BoxCornerDotsGlow[i].Visible = false
        end
    end
    
    -- ═══ NAME ═══
    if Config.Name then
        local namePos = Vector2.new(centerX, top - 20)
        local displayName = player.DisplayName
        local textWidth = #displayName * (Config.NameSize * 0.5)
        
        if Config.NameBackground then
            esp.NameBackground.Position = Vector2.new(centerX - textWidth/2 - 6, top - 32)
            esp.NameBackground.Size = Vector2.new(textWidth + 12, 16)
            esp.NameBackground.Color = Color3.fromRGB(15, 15, 20)
            esp.NameBackground.Transparency = 0.2
            esp.NameBackground.Visible = true
        else
            esp.NameBackground.Visible = false
        end
        
        if Config.NameGlow and Config.BoxGlow then
            esp.NameGlow.Text = displayName
            esp.NameGlow.Position = namePos
            esp.NameGlow.Size = Config.NameSize
            esp.NameGlow.Color = mainColor
            esp.NameGlow.Transparency = pulse
            esp.NameGlow.Visible = true
        else
            esp.NameGlow.Visible = false
        end
        
        esp.NameShadow.Text = displayName
        esp.NameShadow.Position = namePos + Vector2.new(1, 1)
        esp.NameShadow.Size = Config.NameSize
        esp.NameShadow.Visible = true
        
        esp.Name.Text = displayName
        esp.Name.Position = namePos
        esp.Name.Size = Config.NameSize
        esp.Name.Color = mainColor
        esp.Name.Visible = true
    else
        esp.NameBackground.Visible = false
        esp.NameGlow.Visible = false
        esp.NameShadow.Visible = false
        esp.Name.Visible = false
    end
    
    -- ═══ DISTANCE ═══
    if Config.Distance then
        local distPos = Vector2.new(centerX, bottom + 4)
        local distText = "[" .. floor(distance) .. "m]"
        
        esp.DistanceShadow.Text = distText
        esp.DistanceShadow.Position = distPos + Vector2.new(1, 1)
        esp.DistanceShadow.Size = 11
        esp.DistanceShadow.Visible = true
        
        esp.Distance.Text = distText
        esp.Distance.Position = distPos
        esp.Distance.Size = 11
        esp.Distance.Color = Color3.fromRGB(180, 180, 195)
        esp.Distance.Visible = true
    else
        esp.DistanceShadow.Visible = false
        esp.Distance.Visible = false
    end
    
    -- ═══ WEAPON ═══
    if Config.Weapon then
        local tool = character:FindFirstChildOfClass("Tool")
        if tool then
            local weapPos = Vector2.new(centerX, bottom + 18)
            local weapText = tool.Name
            local textWidth = #weapText * 5.5
            
            if Config.WeaponBackground then
                esp.WeaponBackground.Position = Vector2.new(centerX - textWidth/2 - 8, bottom + 14)
                esp.WeaponBackground.Size = Vector2.new(textWidth + 16, 16)
                esp.WeaponBackground.Color = Color3.fromRGB(15, 15, 20)
                esp.WeaponBackground.Transparency = 0.2
                esp.WeaponBackground.Visible = true
            else
                esp.WeaponBackground.Visible = false
            end
            
            esp.WeaponShadow.Text = weapText
            esp.WeaponShadow.Position = weapPos + Vector2.new(1, 1)
            esp.WeaponShadow.Size = 10
            esp.WeaponShadow.Visible = true
            
            esp.Weapon.Text = weapText
            esp.Weapon.Position = weapPos
            esp.Weapon.Size = 10
            esp.Weapon.Color = Color3.fromRGB(255, 200, 100)
            esp.Weapon.Visible = true
        else
            esp.WeaponBackground.Visible = false
            esp.WeaponShadow.Visible = false
            esp.Weapon.Visible = false
        end
    else
        esp.WeaponBackground.Visible = false
        esp.WeaponShadow.Visible = false
        esp.Weapon.Visible = false
    end
    
    -- ═══ HEALTH ═══
    if Config.Health then
        local healthPercent = clamp(humanoid.Health / humanoid.MaxHealth, 0, 1)
        smooth.health = Lerp(smooth.health, healthPercent, clamp(deltaTime * 10, 0, 1))
        local smoothHealth = smooth.health
        local healthColor = GetHealthColor(smoothHealth)
        
        local barWidth = 3
        local barHeight = height
        local barX = left - barWidth - 6
        local barY = top
        
        local segCount = Config.HealthSegments
        local segGap = 1
        local segHeight = (barHeight - (segCount - 1) * segGap) / segCount
        
        esp.HealthOutline.Position = Vector2.new(barX - 2, barY - 2)
        esp.HealthOutline.Size = Vector2.new(barWidth + 4, barHeight + 4)
        esp.HealthOutline.Visible = true
        
        esp.HealthBackground.Position = Vector2.new(barX - 1, barY - 1)
        esp.HealthBackground.Size = Vector2.new(barWidth + 2, barHeight + 2)
        esp.HealthBackground.Color = Color3.fromRGB(15, 15, 20)
        esp.HealthBackground.Visible = true
        
        if Config.HealthGlow and Config.BoxGlow then
            local glowH = barHeight * smoothHealth
            esp.HealthGlow.Position = Vector2.new(barX - 3, top + (barHeight - glowH) - 3)
            esp.HealthGlow.Size = Vector2.new(barWidth + 6, glowH + 6)
            esp.HealthGlow.Color = healthColor
            esp.HealthGlow.Transparency = pulse + 0.2
            esp.HealthGlow.Visible = true
        else
            esp.HealthGlow.Visible = false
        end
        
        local filledSegs = floor(smoothHealth * segCount + 0.5)
        for i = 1, segCount do
            if esp.HealthSegments[i] then
                local segY = barY + (segCount - i) * (segHeight + segGap)
                local segColor = GetHealthColor(i / segCount)
                esp.HealthSegments[i].Position = Vector2.new(barX, segY)
                esp.HealthSegments[i].Size = Vector2.new(barWidth, segHeight)
                esp.HealthSegments[i].Color = i <= filledSegs and segColor or Color3.fromRGB(25, 25, 30)
                esp.HealthSegments[i].Transparency = i <= filledSegs and 0 or 0.5
                esp.HealthSegments[i].Visible = true
            end
        end
        
        if Config.HealthText and smoothHealth < 0.99 then
            esp.HealthText.Text = floor(humanoid.Health)
            esp.HealthText.Position = Vector2.new(barX + barWidth/2, barY - 14)
            esp.HealthText.Color = healthColor
            esp.HealthText.Size = 10
            esp.HealthText.Visible = true
        else
            esp.HealthText.Visible = false
        end
    else
        esp.HealthOutline.Visible = false
        esp.HealthBackground.Visible = false
        esp.HealthGlow.Visible = false
        esp.HealthText.Visible = false
        for i = 1, #esp.HealthSegments do esp.HealthSegments[i].Visible = false end
    end
    
    -- ═══ TRACER ═══
    if Config.Tracer then
        local screenSize = Camera.ViewportSize
        local startPos
        if Config.TracerOrigin == "Bottom" then
            startPos = Vector2.new(screenSize.X / 2, screenSize.Y)
        elseif Config.TracerOrigin == "Top" then
            startPos = Vector2.new(screenSize.X / 2, 0)
        elseif Config.TracerOrigin == "Center" then
            startPos = screenSize / 2
        else
            startPos = UserInputService:GetMouseLocation()
        end
        
        local endPos = Vector2.new(centerX, bottom)
        local segments = Config.TracerSegments
        
        for i = 1, segments do
            if esp.TracerGlows[i] and esp.TracerLines[i] then
                local t1 = (i - 1) / segments
                local t2 = i / segments
                local tMid = (t1 + t2) / 2
                
                local from = LerpVector2(startPos, endPos, t1)
                local to = LerpVector2(startPos, endPos, t2)
                local segColor = LerpColor(Color3.fromRGB(50, 50, 70), mainColor, SmoothStep(tMid))
                
                if Config.TracerGlow and Config.BoxGlow then
                    esp.TracerGlows[i].From = from
                    esp.TracerGlows[i].To = to
                    esp.TracerGlows[i].Color = segColor
                    esp.TracerGlows[i].Transparency = Lerp(0.9, pulse, SmoothStep(tMid))
                    esp.TracerGlows[i].Visible = true
                else
                    esp.TracerGlows[i].Visible = false
                end
                
                esp.TracerLines[i].From = from
                esp.TracerLines[i].To = to
                esp.TracerLines[i].Color = segColor
                esp.TracerLines[i].Transparency = Lerp(0.6, 0, SmoothStep(tMid))
                esp.TracerLines[i].Visible = true
            end
        end
    else
        for i = 1, #esp.TracerGlows do
            if esp.TracerGlows[i] then esp.TracerGlows[i].Visible = false end
            if esp.TracerLines[i] then esp.TracerLines[i].Visible = false end
        end
    end
    
    -- ═══ SKELETON ═══
    if Config.Skeleton then
        local bones = {
            {"Head", "UpperTorso"},
            {"UpperTorso", "LeftUpperArm"}, {"LeftUpperArm", "LeftLowerArm"}, {"LeftLowerArm", "LeftHand"},
            {"UpperTorso", "RightUpperArm"}, {"RightUpperArm", "RightLowerArm"}, {"RightLowerArm", "RightHand"},
            {"UpperTorso", "LowerTorso"},
            {"LowerTorso", "LeftUpperLeg"}, {"LeftUpperLeg", "LeftLowerLeg"}, {"LeftLowerLeg", "LeftFoot"},
            {"LowerTorso", "RightUpperLeg"}, {"RightUpperLeg", "RightLowerLeg"}, {"RightLowerLeg", "RightFoot"}
        }
        
        local r6 = {
            {"Head", "Torso"},
            {"Torso", "Left Arm"}, {"Torso", "Left Arm"}, {"Torso", "Left Arm"},
            {"Torso", "Right Arm"}, {"Torso", "Right Arm"}, {"Torso", "Right Arm"},
            {"Torso", "Torso"},
            {"Torso", "Left Leg"}, {"Torso", "Left Leg"}, {"Torso", "Left Leg"},
            {"Torso", "Right Leg"}, {"Torso", "Right Leg"}, {"Torso", "Right Leg"}
        }
        
        local boneList = character:FindFirstChild("UpperTorso") and bones or r6
        local jointPositions = {}
        
        for i, pair in ipairs(boneList) do
            local p1 = character:FindFirstChild(pair[1])
            local p2 = character:FindFirstChild(pair[2])
            
            if p1 and p2 and p1 ~= p2 and esp.SkeletonGlows[i] and esp.SkeletonBones[i] then
                local pos1, on1 = WorldToScreen(p1.Position)
                local pos2, on2 = WorldToScreen(p2.Position)
                
                if on1 and on2 then
                    if Config.SkeletonGlow and Config.BoxGlow then
                        esp.SkeletonGlows[i].From = pos1
                        esp.SkeletonGlows[i].To = pos2
                        esp.SkeletonGlows[i].Color = mainColor
                        esp.SkeletonGlows[i].Transparency = pulse + 0.2
                        esp.SkeletonGlows[i].Visible = true
                    else
                        esp.SkeletonGlows[i].Visible = false
                    end
                    
                    esp.SkeletonBones[i].From = pos1
                    esp.SkeletonBones[i].To = pos2
                    esp.SkeletonBones[i].Color = mainColor
                    esp.SkeletonBones[i].Thickness = Config.SkeletonThickness / 10
                    esp.SkeletonBones[i].Visible = true
                    
                    jointPositions[tostring(pos1)] = {pos = pos1, color = lightColor}
                    jointPositions[tostring(pos2)] = {pos = pos2, color = lightColor}
                else
                    esp.SkeletonGlows[i].Visible = false
                    esp.SkeletonBones[i].Visible = false
                end
            elseif esp.SkeletonGlows[i] and esp.SkeletonBones[i] then
                esp.SkeletonGlows[i].Visible = false
                esp.SkeletonBones[i].Visible = false
            end
        end
        
        local jointIndex = 1
        for _, data in pairs(jointPositions) do
            if esp.SkeletonJoints[jointIndex] then
                esp.SkeletonJoints[jointIndex].Position = data.pos
                esp.SkeletonJoints[jointIndex].Color = data.color
                esp.SkeletonJoints[jointIndex].Visible = true
                jointIndex = jointIndex + 1
            end
        end
        for i = jointIndex, #esp.SkeletonJoints do
            if esp.SkeletonJoints[i] then esp.SkeletonJoints[i].Visible = false end
        end
    else
        for i = 1, #esp.SkeletonGlows do
            if esp.SkeletonGlows[i] then esp.SkeletonGlows[i].Visible = false end
            if esp.SkeletonBones[i] then esp.SkeletonBones[i].Visible = false end
        end
        for i = 1, #esp.SkeletonJoints do
            if esp.SkeletonJoints[i] then esp.SkeletonJoints[i].Visible = false end
        end
    end
    
    -- ═══ HEAD DOT ═══
    if Config.HeadDot and head then
        local headPos, headOn = WorldToScreen(head.Position)
        if headOn then
            local dotSize = clamp(Config.HeadDotSize - bbox.Depth / 150, 2, Config.HeadDotSize + 2)
            dotSize = dotSize * breathe
            
            if Config.BoxGlow then
                esp.HeadGlowOuter.Position = headPos
                esp.HeadGlowOuter.Radius = dotSize + 6
                esp.HeadGlowOuter.Color = mainColor
                esp.HeadGlowOuter.Transparency = pulse + 0.3
                esp.HeadGlowOuter.Visible = true
                
                esp.HeadGlowInner.Position = headPos
                esp.HeadGlowInner.Radius = dotSize + 3
                esp.HeadGlowInner.Color = lightColor
                esp.HeadGlowInner.Transparency = pulse
                esp.HeadGlowInner.Visible = true
            else
                esp.HeadGlowOuter.Visible = false
                esp.HeadGlowInner.Visible = false
            end
            
            esp.HeadOutline.Position = headPos
            esp.HeadOutline.Radius = dotSize + 2
            esp.HeadOutline.Visible = true
            
            esp.HeadDot.Position = headPos
            esp.HeadDot.Radius = dotSize
            esp.HeadDot.Color = lightColor
            esp.HeadDot.Visible = true
        else
            esp.HeadGlowOuter.Visible = false
            esp.HeadGlowInner.Visible = false
            esp.HeadOutline.Visible = false
            esp.HeadDot.Visible = false
        end
    else
        esp.HeadGlowOuter.Visible = false
        esp.HeadGlowInner.Visible = false
        esp.HeadOutline.Visible = false
        esp.HeadDot.Visible = false
    end
    
    -- ═══ LOOK DIRECTION ═══
    if Config.LookDirection and head then
        local headPos, headOn = WorldToScreen(head.Position)
        local lookVector = head.CFrame.LookVector
        local lookEndWorld = head.Position + lookVector * (Config.LookLength / 10)
        local lookEndPos, lookEndOn = WorldToScreen(lookEndWorld)
        
        if headOn and lookEndOn then
            local lookColor = Color3.fromRGB(120, 255, 214)
            
            if Config.BoxGlow then
                esp.LookGlow.From = headPos
                esp.LookGlow.To = lookEndPos
                esp.LookGlow.Color = lookColor
                esp.LookGlow.Thickness = 4
                esp.LookGlow.Transparency = pulse + 0.2
                esp.LookGlow.Visible = true
            else
                esp.LookGlow.Visible = false
            end
            
            esp.LookLine.From = headPos
            esp.LookLine.To = lookEndPos
            esp.LookLine.Color = lookColor
            esp.LookLine.Thickness = 1.5
            esp.LookLine.Visible = true
            
            local dir = (lookEndPos - headPos).Unit
            local arrowSize = 6
            local angle = atan2(dir.Y, dir.X)
            
            local ap1 = lookEndPos
            local ap2 = lookEndPos - Vector2.new(cos(angle - 0.5) * arrowSize, sin(angle - 0.5) * arrowSize)
            local ap3 = lookEndPos - Vector2.new(cos(angle + 0.5) * arrowSize, sin(angle + 0.5) * arrowSize)
            
            esp.LookArrow.PointA = ap1
            esp.LookArrow.PointB = ap2
            esp.LookArrow.PointC = ap3
            esp.LookArrow.Color = lookColor
            esp.LookArrow.Visible = true
        else
            esp.LookGlow.Visible = false
            esp.LookLine.Visible = false
            esp.LookArrow.Visible = false
        end
    else
        esp.LookGlow.Visible = false
        esp.LookLine.Visible = false
        esp.LookArrow.Visible = false
    end
    
    -- ═══ CHAMS ═══
    if Config.Chams then
        local chamsPulse = GetBreathing(1.5, 0.4, 0.7)
        esp.Highlight.FillColor = mainColor
        esp.Highlight.OutlineColor = lightColor
        esp.Highlight.FillTransparency = chamsPulse
        esp.Highlight.Adornee = character
        esp.Highlight.Parent = character
    else
        esp.Highlight.Parent = nil
    end
end

-- ════════════════════════════════════════════════════════════════════════════════
-- CROSSHAIR
-- ════════════════════════════════════════════════════════════════════════════════

local Crosshair = {
    TopGlow = NewDrawing("Line", { Thickness = 4 }),
    Top = NewDrawing("Line", { Thickness = 1.5 }),
    BottomGlow = NewDrawing("Line", { Thickness = 4 }),
    Bottom = NewDrawing("Line", { Thickness = 1.5 }),
    LeftGlow = NewDrawing("Line", { Thickness = 4 }),
    Left = NewDrawing("Line", { Thickness = 1.5 }),
    RightGlow = NewDrawing("Line", { Thickness = 4 }),
    Right = NewDrawing("Line", { Thickness = 1.5 }),
    DotGlow = NewDrawing("Circle", { Filled = true, NumSides = 24 }),
    Dot = NewDrawing("Circle", { Filled = true, NumSides = 24 }),
    Ring = NewDrawing("Circle", { Filled = false, NumSides = 48, Thickness = 1.5 })
}

local function UpdateCrosshair()
    if not Config.Crosshair then
        for _, v in pairs(Crosshair) do v.Visible = false end
        return
    end
    
    local center = Camera.ViewportSize / 2
    local gap = 6
    local size = 14
    local color = Color3.fromRGB(147, 112, 219)
    local pulse = GetPulse(3, 0.4, 0.7)
    local breathe = GetBreathing(2, 0.9, 1.1)
    
    Crosshair.TopGlow.From = Vector2.new(center.X, center.Y - gap)
    Crosshair.TopGlow.To = Vector2.new(center.X, center.Y - gap - size)
    Crosshair.TopGlow.Color = color
    Crosshair.TopGlow.Transparency = pulse
    Crosshair.TopGlow.Visible = true
    
    Crosshair.Top.From = Crosshair.TopGlow.From
    Crosshair.Top.To = Crosshair.TopGlow.To
    Crosshair.Top.Color = color
    Crosshair.Top.Visible = true
    
    Crosshair.BottomGlow.From = Vector2.new(center.X, center.Y + gap)
    Crosshair.BottomGlow.To = Vector2.new(center.X, center.Y + gap + size)
    Crosshair.BottomGlow.Color = color
    Crosshair.BottomGlow.Transparency = pulse
    Crosshair.BottomGlow.Visible = true
    
    Crosshair.Bottom.From = Crosshair.BottomGlow.From
    Crosshair.Bottom.To = Crosshair.BottomGlow.To
    Crosshair.Bottom.Color = color
    Crosshair.Bottom.Visible = true
    
    Crosshair.LeftGlow.From = Vector2.new(center.X - gap, center.Y)
    Crosshair.LeftGlow.To = Vector2.new(center.X - gap - size, center.Y)
    Crosshair.LeftGlow.Color = color
    Crosshair.LeftGlow.Transparency = pulse
    Crosshair.LeftGlow.Visible = true
    
    Crosshair.Left.From = Crosshair.LeftGlow.From
    Crosshair.Left.To = Crosshair.LeftGlow.To
    Crosshair.Left.Color = color
    Crosshair.Left.Visible = true
    
    Crosshair.RightGlow.From = Vector2.new(center.X + gap, center.Y)
    Crosshair.RightGlow.To = Vector2.new(center.X + gap + size, center.Y)
    Crosshair.RightGlow.Color = color
    Crosshair.RightGlow.Transparency = pulse
    Crosshair.RightGlow.Visible = true
    
    Crosshair.Right.From = Crosshair.RightGlow.From
    Crosshair.Right.To = Crosshair.RightGlow.To
    Crosshair.Right.Color = color
    Crosshair.Right.Visible = true
    
    Crosshair.DotGlow.Position = center
    Crosshair.DotGlow.Radius = 6
    Crosshair.DotGlow.Color = color
    Crosshair.DotGlow.Transparency = pulse
    Crosshair.DotGlow.Visible = true
    
    Crosshair.Dot.Position = center
    Crosshair.Dot.Radius = 3
    Crosshair.Dot.Color = Color3.fromRGB(180, 150, 255)
    Crosshair.Dot.Visible = true
    
    local ringRadius = 18 * breathe
    Crosshair.Ring.Position = center
    Crosshair.Ring.Radius = ringRadius
    Crosshair.Ring.Color = color
    Crosshair.Ring.Transparency = 0.4
    Crosshair.Ring.Visible = true
end

-- ════════════════════════════════════════════════════════════════════════════════
-- WATERMARK
-- ════════════════════════════════════════════════════════════════════════════════

local Watermark = {
    Background = NewDrawing("Square", { Filled = true }),
    Border = NewDrawing("Line", {}),
    Logo = NewDrawing("Text", { Font = Drawing.Fonts.Plex }),
    Divider = NewDrawing("Line", {}),
    FPS = NewDrawing("Text", { Font = Drawing.Fonts.Plex }),
    Ping = NewDrawing("Text", { Font = Drawing.Fonts.Plex })
}

local fpsCounter = 0
local lastFPSTick = tick()
local currentFPS = 0

local function UpdateWatermark()
    if not Config.Watermark then
        for _, v in pairs(Watermark) do v.Visible = false end
        return
    end
    
    fpsCounter = fpsCounter + 1
    if tick() - lastFPSTick >= 1 then
        currentFPS = fpsCounter
        fpsCounter = 0
        lastFPSTick = tick()
    end
    
    local ping = 0
    pcall(function()
        ping = game:GetService("Stats").Network.ServerStatsItem["Data Ping"]:GetValue()
    end)
    
    local x = Camera.ViewportSize.X - 220
    local y = 12
    local width = 200
    local height = 32
    
    Watermark.Background.Position = Vector2.new(x, y)
    Watermark.Background.Size = Vector2.new(width, height)
    Watermark.Background.Color = Color3.fromRGB(15, 15, 20)
    Watermark.Background.Transparency = 0.1
    Watermark.Background.Visible = true
    
    Watermark.Border.From = Vector2.new(x, y)
    Watermark.Border.To = Vector2.new(x + width, y)
    Watermark.Border.Color = Color3.fromRGB(147, 112, 219)
    Watermark.Border.Thickness = 2
    Watermark.Border.Visible = true
    
    Watermark.Logo.Text = "JCHEATS"
    Watermark.Logo.Position = Vector2.new(x + 12, y + 9)
    Watermark.Logo.Size = 13
    Watermark.Logo.Color = Color3.fromRGB(147, 112, 219)
    Watermark.Logo.Visible = true
    
    Watermark.Divider.From = Vector2.new(x + 80, y + 8)
    Watermark.Divider.To = Vector2.new(x + 80, y + height - 8)
    Watermark.Divider.Color = Color3.fromRGB(50, 50, 70)
    Watermark.Divider.Thickness = 1
    Watermark.Divider.Visible = true
    
    local fpsColor = currentFPS >= 60 and Color3.fromRGB(80, 255, 120) or
                     currentFPS >= 30 and Color3.fromRGB(255, 200, 80) or Color3.fromRGB(255, 80, 80)
    
    Watermark.FPS.Text = currentFPS .. " FPS"
    Watermark.FPS.Position = Vector2.new(x + 90, y + 9)
    Watermark.FPS.Size = 11
    Watermark.FPS.Color = fpsColor
    Watermark.FPS.Visible = Config.FPSCounter
    
    local pingColor = ping <= 50 and Color3.fromRGB(80, 255, 120) or
                      ping <= 100 and Color3.fromRGB(255, 200, 80) or Color3.fromRGB(255, 80, 80)
    
    Watermark.Ping.Text = floor(ping) .. "ms"
    Watermark.Ping.Position = Vector2.new(x + 150, y + 9)
    Watermark.Ping.Size = 11
    Watermark.Ping.Color = pingColor
    Watermark.Ping.Visible = true
end

-- ════════════════════════════════════════════════════════════════════════════════
-- INITIALIZATION
-- ════════════════════════════════════════════════════════════════════════════════

for _, player in ipairs(Players:GetPlayers()) do
    if player ~= LocalPlayer then
        ESPObjects[player] = CreateESP(player)
    end
end

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        task.wait(0.5)
        if not ESPObjects[player] then
            ESPObjects[player] = CreateESP(player)
        end
    end)
end)

Players.PlayerRemoving:Connect(function(player)
    DestroyESP(player)
end)

-- ════════════════════════════════════════════════════════════════════════════════
-- RENDER LOOP
-- ════════════════════════════════════════════════════════════════════════════════

RunService.RenderStepped:Connect(function()
    Camera = workspace.CurrentCamera
    
    for player, esp in pairs(ESPObjects) do
        if player and player.Parent then
            UpdateESP(player, esp)
        else
            DestroyESP(player)
        end
    end
    
    UpdateCrosshair()
    UpdateWatermark()
end)

-- ════════════════════════════════════════════════════════════════════════════════
-- GUI MENU
-- ════════════════════════════════════════════════════════════════════════════════

local gui_config = {
    Color = Color3.fromRGB(147, 112, 219),
    Keybind = Enum.KeyCode.RightShift
}

local library = loadstring(game:HttpGet("https://raw.githubusercontent.com/nfpw/XXSCRIPT/main/Library/Module.lua"))()
local window = library:CreateWindow(gui_config, gethui())

pcall(function()
    library:SetWindowName("JCHEATS Masterpiece | " .. MarketplaceService:GetProductInfo(game.PlaceId).Name)
end)

library.flags = library.flags or {}

-- Tabs
local tabs = {
    main = window:CreateTab("Main"),
    box = window:CreateTab("Box"),
    info = window:CreateTab("Info"),
    lines = window:CreateTab("Lines"),
    extras = window:CreateTab("Extras"),
    colors = window:CreateTab("Colors"),
    settings = window:CreateTab("Settings")
}

-- ═══ MAIN TAB ═══
local general_section = tabs.main:CreateSection("General", "left")
local performance_section = tabs.main:CreateSection("Performance", "right")

general_section:CreateToggle("Enable ESP", Config.Enabled, function(v) Config.Enabled = v end)
general_section:CreateToggle("Team Check", Config.TeamCheck, function(v) Config.TeamCheck = v end)
general_section:CreateSlider("Max Distance", 100, 5000, Config.MaxDistance, true, function(v) Config.MaxDistance = v end)

performance_section:CreateToggle("Dynamic Box", Config.DynamicBox, function(v) Config.DynamicBox = v end)
performance_section:CreateToggle("Smooth Movement", Config.SmoothMovement, function(v) Config.SmoothMovement = v end)
performance_section:CreateSlider("Animation Speed", 1, 100, Config.AnimationSpeed, true, function(v) Config.AnimationSpeed = v end)

-- ═══ BOX TAB ═══
local box_section = tabs.box:CreateSection("Box ESP", "left")
local box_effects = tabs.box:CreateSection("Effects", "right")

box_section:CreateToggle("Enable Box", Config.Box, function(v) Config.Box = v end)
box_section:CreateSlider("Padding", 0, 20, Config.BoxPadding, true, function(v) Config.BoxPadding = v end)
box_section:CreateSlider("Corner Length %", 10, 50, Config.BoxCornerLength, true, function(v) Config.BoxCornerLength = v end)

box_effects:CreateToggle("Box Glow", Config.BoxGlow, function(v) Config.BoxGlow = v end)
box_effects:CreateSlider("Glow Intensity", 0, 100, Config.BoxGlowIntensity, true, function(v) Config.BoxGlowIntensity = v end)
box_effects:CreateToggle("Box Fill", Config.BoxFill, function(v) Config.BoxFill = v end)
box_effects:CreateSlider("Fill Opacity", 0, 100, Config.BoxFillOpacity, true, function(v) Config.BoxFillOpacity = v end)
box_effects:CreateToggle("Box Gradient", Config.BoxGradient, function(v) Config.BoxGradient = v end)
box_effects:CreateToggle("Accent Lines", Config.BoxAccentLines, function(v) Config.BoxAccentLines = v end)
box_effects:CreateToggle("Corner Dots", Config.BoxCornerDots, function(v) Config.BoxCornerDots = v end)

-- ═══ INFO TAB ═══
local name_section = tabs.info:CreateSection("Name", "left")
local info_section = tabs.info:CreateSection("Info", "right")

name_section:CreateToggle("Show Name", Config.Name, function(v) Config.Name = v end)
name_section:CreateToggle("Name Glow", Config.NameGlow, function(v) Config.NameGlow = v end)
name_section:CreateToggle("Name Background", Config.NameBackground, function(v) Config.NameBackground = v end)
name_section:CreateSlider("Name Size", 10, 20, Config.NameSize, true, function(v) Config.NameSize = v end)

info_section:CreateToggle("Show Distance", Config.Distance, function(v) Config.Distance = v end)
info_section:CreateToggle("Show Weapon", Config.Weapon, function(v) Config.Weapon = v end)
info_section:CreateToggle("Weapon Background", Config.WeaponBackground, function(v) Config.WeaponBackground = v end)

-- ═══ LINES TAB ═══
local health_section = tabs.lines:CreateSection("Health", "left")
local tracer_section = tabs.lines:CreateSection("Tracers", "left")
local skeleton_section = tabs.lines:CreateSection("Skeleton", "right")

health_section:CreateToggle("Enable Health", Config.Health, function(v) Config.Health = v end)
health_section:CreateSlider("Segments", 5, 20, Config.HealthSegments, true, function(v) Config.HealthSegments = v end)
health_section:CreateToggle("Health Glow", Config.HealthGlow, function(v) Config.HealthGlow = v end)
health_section:CreateToggle("Health Text", Config.HealthText, function(v) Config.HealthText = v end)

tracer_section:CreateToggle("Enable Tracers", Config.Tracer, function(v) Config.Tracer = v end)
tracer_section:CreateToggle("Tracer Glow", Config.TracerGlow, function(v) Config.TracerGlow = v end)
tracer_section:CreateSlider("Segments", 8, 32, Config.TracerSegments, true, function(v) Config.TracerSegments = v end)
tracer_section:CreateDropdown("Origin", {"Bottom", "Top", "Center", "Mouse"}, function(v) Config.TracerOrigin = v end, "Bottom", false)

skeleton_section:CreateToggle("Enable Skeleton", Config.Skeleton, function(v) Config.Skeleton = v end)
skeleton_section:CreateToggle("Skeleton Glow", Config.SkeletonGlow, function(v) Config.SkeletonGlow = v end)
skeleton_section:CreateSlider("Thickness", 10, 30, Config.SkeletonThickness, true, function(v) Config.SkeletonThickness = v end)

-- ═══ EXTRAS TAB ═══
local head_section = tabs.extras:CreateSection("Head Dot", "left")
local look_section = tabs.extras:CreateSection("Look Direction", "left")
local arrow_section = tabs.extras:CreateSection("Off-Screen", "right")
local chams_section = tabs.extras:CreateSection("Chams", "right")

head_section:CreateToggle("Enable Head Dot", Config.HeadDot, function(v) Config.HeadDot = v end)
head_section:CreateSlider("Size", 2, 10, Config.HeadDotSize, true, function(v) Config.HeadDotSize = v end)

look_section:CreateToggle("Enable Look Direction", Config.LookDirection, function(v) Config.LookDirection = v end)
look_section:CreateSlider("Length", 20, 80, Config.LookLength, true, function(v) Config.LookLength = v end)

arrow_section:CreateToggle("Enable Arrows", Config.OffScreenArrows, function(v) Config.OffScreenArrows = v end)
arrow_section:CreateSlider("Arrow Size", 10, 30, Config.ArrowSize, true, function(v) Config.ArrowSize = v end)
arrow_section:CreateSlider("Distance", 80, 200, Config.ArrowDistance, true, function(v) Config.ArrowDistance = v end)

chams_section:CreateToggle("Enable Chams", Config.Chams, function(v) Config.Chams = v end)
chams_section:CreateSlider("Opacity", 0, 100, Config.ChamsOpacity, true, function(v) Config.ChamsOpacity = v end)

-- ═══ COLORS TAB ═══
local enemy_color_section = tabs.colors:CreateSection("Enemy Colors", "left")
local team_color_section = tabs.colors:CreateSection("Team Colors", "left")
local theme_section = tabs.colors:CreateSection("Theme Settings", "right")

enemy_color_section:CreateColorpicker("Enemy Main", function(color)
    Config.EnemyColor = color
end, false, false, nil)

enemy_color_section:CreateColorpicker("Enemy Light", function(color)
    Config.EnemyColorLight = color
end, false, false, nil)

team_color_section:CreateColorpicker("Team Main", function(color)
    Config.TeamColor = color
end, false, false, nil)

team_color_section:CreateColorpicker("Team Light", function(color)
    Config.TeamColorLight = color
end, false, false, nil)

theme_section:CreateToggle("Glow Pulse Effect", Config.GlowPulse, function(v)
    Config.GlowPulse = v
end)

theme_section:CreateSlider("Glow Intensity", 0, 100, Config.BoxGlowIntensity, true, function(v)
    Config.BoxGlowIntensity = v
end)

theme_section:CreateSlider("Animation Speed", 1, 100, Config.AnimationSpeed, true, function(v)
    Config.AnimationSpeed = v
end)

-- ═══ SETTINGS TAB ═══
local ui_elements_section = tabs.settings:CreateSection("UI Elements", "left")
local config_section = tabs.settings:CreateSection("Configuration", "right")
local credits_section = tabs.settings:CreateSection("Credits", "right")

ui_elements_section:CreateToggle("Crosshair", Config.Crosshair, function(v)
    Config.Crosshair = v
end)

ui_elements_section:CreateToggle("Watermark", Config.Watermark, function(v)
    Config.Watermark = v
end)

ui_elements_section:CreateToggle("FPS Counter", Config.FPSCounter, function(v)
    Config.FPSCounter = v
end)

ui_elements_section:CreateToggle("Target Info", Config.TargetInfo, function(v)
    Config.TargetInfo = v
end)

config_section:CreateButton("Save Config", function()
    local success = pcall(function()
        if writefile then
            local configData = HttpService:JSONEncode(Config)
            writefile("JCHEATS_ESP_Config.json", configData)
        end
    end)
    if success then
        library:Notification("Config", "Saved successfully!", 3)
    else
        library:Notification("Error", "Failed to save", 3)
    end
end)

config_section:CreateButton("Load Config", function()
    local success = pcall(function()
        if readfile and isfile and isfile("JCHEATS_ESP_Config.json") then
            local data = readfile("JCHEATS_ESP_Config.json")
            local loaded = HttpService:JSONDecode(data)
            for k, v in pairs(loaded) do
                if Config[k] ~= nil then
                    Config[k] = v
                end
            end
        end
    end)
    if success then
        library:Notification("Config", "Loaded!", 3)
    else
        library:Notification("Error", "Failed to load", 3)
    end
end)

config_section:CreateButton("Reset Default", function()
    Config.Enabled = true
    Config.TeamCheck = false
    Config.MaxDistance = 2500
    Config.Box = true
    Config.DynamicBox = true
    Config.BoxGlow = true
    Config.BoxFill = true
    Config.Name = true
    Config.Health = true
    Config.Distance = true
    Config.Tracer = true
    Config.Skeleton = true
    Config.HeadDot = true
    Config.Chams = true
    Config.Crosshair = true
    Config.Watermark = true
    library:Notification("Config", "Reset to defaults!", 3)
end)

credits_section:CreateButton("Discord (Copy)", function()
    if setclipboard then
        setclipboard("discord.gg/jcheats")
        library:Notification("Copied", "Discord link copied!", 2)
    end
end)

-- ════════════════════════════════════════════════════════════════════════════════
-- KEYBIND HANDLER
-- ════════════════════════════════════════════════════════════════════════════════

UserInputService.InputBegan:Connect(function(input, processed)
    if processed then return end
    
    if input.KeyCode == gui_config.Keybind then
        library:ToggleUI()
    end
    
    if input.KeyCode == Enum.KeyCode.F1 then
        Config.Enabled = not Config.Enabled
        library:Notification("ESP", Config.Enabled and "Enabled" or "Disabled", 2)
    end
    
    if input.KeyCode == Enum.KeyCode.F2 then
        Config.Box = not Config.Box
        library:Notification("Box", Config.Box and "Enabled" or "Disabled", 2)
    end
    
    if input.KeyCode == Enum.KeyCode.F3 then
        Config.Skeleton = not Config.Skeleton
        library:Notification("Skeleton", Config.Skeleton and "Enabled" or "Disabled", 2)
    end
    
    if input.KeyCode == Enum.KeyCode.F4 then
        Config.Chams = not Config.Chams
        library:Notification("Chams", Config.Chams and "Enabled" or "Disabled", 2)
    end
end)

-- ════════════════════════════════════════════════════════════════════════════════
-- STARTUP
-- ════════════════════════════════════════════════════════════════════════════════

task.spawn(function()
    task.wait(1)
    library:Notification("JCHEATS", "Masterpiece ESP loaded!", 5)
    library:Notification("Menu", "Press RightShift to toggle", 3)
end)

print([[
╔══════════════════════════════════════════════════════════════╗
║              JCHEATS Masterpiece ESP Loaded!                 ║
║                                                              ║
║  RightShift - Menu | F1 - ESP | F2 - Box                    ║
║  F3 - Skeleton | F4 - Chams                                  ║
║                                                              ║
║                    Made by Bin for Jack ♡                    ║
╚══════════════════════════════════════════════════════════════╝
]])

Features & Information

esp by CLAUDE OPUS 4.5
#esp#ai#open source#universal

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts