local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer local Camera = workspace.CurrentCamera -- GUI local espGui = Instance.new("ScreenGui", LocalPlayer.PlayerGui) espGui.Name = "OptimizedESP" espGui.ResetOnSpawn = false -- Settings local maxDistance = 1000 local refreshRate = 5 local espEnabled = true local espObjects = {} local lastUpdate = 0 local rarityColors = { common = Color3.fromRGB(78, 53, 152), uncommon = Color3.fromRGB(47, 249, 36), rare = Color3.fromRGB(128, 49, 167), epic = Color3.fromRGB(188, 0, 227), legendary = Color3.fromRGB(255, 233, 0), ultimate = Color3.fromRGB(128, 5, 0), resplendent = Color3.fromRGB(25, 25, 25), default = Color3.fromRGB(255, 255, 255), } -- Helper to get player position local function getPlayerPosition() local character = LocalPlayer.Character if character and character:FindFirstChild("HumanoidRootPart") then return character.HumanoidRootPart.Position end return Camera.CFrame.Position end -- Helper to create ESP Billboard local function createESP(object, color) local billboard = Instance.new("BillboardGui") billboard.AlwaysOnTop = true billboard.Size = UDim2.new(0, 200, 0, 20) billboard.StudsOffset = Vector3.new(0, 2, 0) billboard.LightInfluence = 0 billboard.MaxDistance = maxDistance billboard.Name = "ESP_Billboard" local label = Instance.new("TextLabel", billboard) label.Size = UDim2.new(1, 0, 1, 0) label.BackgroundTransparency = 1 label.TextColor3 = color label.TextStrokeTransparency = 0.4 label.TextStrokeColor3 = Color3.new(0, 0, 0) label.Font = Enum.Font.SourceSansBold label.TextScaled = true label.Text = "" billboard.Parent = object return billboard, label end -- Toggle key UserInputService.InputBegan:Connect(function(input, processed) if not processed and input.KeyCode == Enum.KeyCode.X then espEnabled = not espEnabled espGui.Enabled = espEnabled for _, data in pairs(espObjects) do if data.gui then data.gui.Enabled = espEnabled end end end end) -- Main update loop RunService.Heartbeat:Connect(function() if tick() - lastUpdate < refreshRate then return end lastUpdate = tick() local playerPos = getPlayerPosition() -- Update or create ESP for _, descendant in ipairs(workspace:GetDescendants()) do local pillow = descendant:FindFirstChild("Pillow") if pillow and pillow:IsA("StringValue") then local part = descendant:IsA("BasePart") and descendant or (descendant:IsA("Model") and descendant.PrimaryPart) if part then if not espObjects[descendant] then local rarity = pillow.Value:lower() local color = rarityColors[rarity] or rarityColors.default local gui, label = createESP(part, color) espObjects[descendant] = {gui = gui, label = label, type = rarity, part = part} end local data = espObjects[descendant] local dist = (playerPos - data.part.Position).Magnitude if dist <= maxDistance and espEnabled then data.gui.Enabled = true data.label.Text = string.format("%s (%d)", data.type:upper(), dist) else data.gui.Enabled = false end end end end -- Cleanup destroyed objects for obj, data in pairs(espObjects) do if not obj:IsDescendantOf(workspace) then if data.gui then data.gui:Destroy() end espObjects[obj] = nil end end end)