--// ESP GUI with Toggle //-- -- Create GUI local player = game.Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui") local screenGui = Instance.new("ScreenGui", playerGui) screenGui.Name = "ESPGui" local toggleButton = Instance.new("TextButton", screenGui) toggleButton.Size = UDim2.new(0, 120, 0, 40) toggleButton.Position = UDim2.new(0, 20, 0, 20) toggleButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30) toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) toggleButton.Text = "ESP: OFF" toggleButton.Font = Enum.Font.SourceSansBold toggleButton.TextSize = 20 toggleButton.BorderSizePixel = 0 -- Variables local espEnabled = false local espFolder = Instance.new("Folder") espFolder.Name = "ESPObjects" espFolder.Parent = workspace -- Function to create ESP box local function createESPBox(target) local character = target.Character if not character or not character:FindFirstChild("HumanoidRootPart") then return end local box = Instance.new("BoxHandleAdornment") box.Name = "ESPBox" box.Adornee = character.HumanoidRootPart box.AlwaysOnTop = true box.ZIndex = 0 box.Size = Vector3.new(4, 6, 2) box.Color3 = Color3.fromRGB(255, 0, 0) box.Transparency = 0.5 box.Parent = espFolder end -- Function to remove all ESP local function clearESP() espFolder:ClearAllChildren() end -- Function to update ESP local function updateESP() clearESP() for _, otherPlayer in ipairs(game.Players:GetPlayers()) do if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then createESPBox(otherPlayer) end end end -- Toggle Function local function toggleESP() espEnabled = not espEnabled toggleButton.Text = espEnabled and "ESP: ON" or "ESP: OFF" if not espEnabled then clearESP() else updateESP() end end -- Connect toggle toggleButton.MouseButton1Click:Connect(toggleESP) -- Update ESP on character spawn game.Players.PlayerAdded:Connect(function(p) p.CharacterAdded:Connect(function() if espEnabled then task.wait(1) updateESP() end end) end) -- Periodic refresh while true do if espEnabled then updateESP() end task.wait(2) end