
Key RequiredUniversal

local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
--// GUI
local gui = Instance.new("ScreenGui")
gui.Name = "ESP_GUI"
gui.ResetOnSpawn = false
gui.Parent = localPlayer:WaitForChild("PlayerGui")
local button = Instance.new("TextButton")
button.Name = "ESPButton"
button.Size = UDim2.new(0, 180, 0, 50)
button.Position = UDim2.new(0, 20, 0, 20)
button.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
button.TextColor3 = Color3.fromRGB(255, 255, 255)
button.TextSize = 20
button.Font = Enum.Font.GothamBold
button.Text = "ESP: OFF"
button.Parent = gui
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 10)
corner.Parent = button
--// ESP
local espEnabled = false
local function removeESP(player)
if player.Character then
local highlight = player.Character:FindFirstChild("ESPHighlight")
if highlight then
highlight:Destroy()
end
end
end
local function addESP(player)
if player == localPlayer then
return
end
if not espEnabled then
return
end
local character = player.Character
if not character then
return
end
if character:FindFirstChild("ESPHighlight") then
return
end
local highlight = Instance.new("Highlight")
highlight.Name = "ESPHighlight"
highlight.FillColor = Color3.fromRGB(0, 255, 0)
highlight.OutlineColor = Color3.fromRGB(0, 255, 0)
highlight.FillTransparency = 0.5
highlight.OutlineTransparency = 0
highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
highlight.Parent = character
end
local function updateESP()
for _, player in ipairs(Players:GetPlayers()) do
if player ~= localPlayer then
if espEnabled then
addESP(player)
else
removeESP(player)
end
end
end
end
--// Handle players joining
local function setupPlayer(player)
if player == localPlayer then
return
end
player.CharacterAdded:Connect(function()
task.wait(0.1)
if espEnabled then
addESP(player)
end
end)
if espEnabled then
addESP(player)
end
end
for _, player in ipairs(Players:GetPlayers()) do
setupPlayer(player)
end
Players.PlayerAdded:Connect(setupPlayer)
--// Toggle
button.MouseButton1Click:Connect(function()
espEnabled = not espEnabled
if espEnabled then
button.Text = "ESP: ON"
button.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
else
button.Text = "ESP: OFF"
button.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
end
updateESP()
end)No comments yet for this script.



