-- ESP GUI Script (Place in StarterPlayerScripts or use an executor) local Players = game:GetService("Players") local RunService = game:GetService("RunService") local TweenService = game:GetService("TweenService") local LocalPlayer = Players.LocalPlayer local Camera = workspace.CurrentCamera -- Create ScreenGui local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "ESP" ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui") ScreenGui.ResetOnSpawn = false -- ESP Settings local ESP_CONFIG = { BOX_COLOR = Color3.fromRGB(255, 0, 0), BOX_TRANSPARENCY = 0.7, TEXT_COLOR = Color3.fromRGB(255, 255, 255), TEXT_SIZE = 14, DISTANCE_COLOR = Color3.fromRGB(0, 255, 0), UPDATE_RATE = 1/60 -- 60 FPS } -- Player ESP data table local ESP_DATA = {} -- Create ESP elements for a player local function createESP(player) local data = {} -- Main box data.Box = Instance.new("Frame") data.Box.Size = UDim2.new(0, 0, 0, 0) data.Box.Position = UDim2.new(0, 0, 0, 0) data.Box.BackgroundColor3 = ESP_CONFIG.BOX_COLOR data.Box.BorderSizePixel = 0 data.Box.Parent = ScreenGui local BoxCorner = Instance.new("UICorner") BoxCorner.CornerRadius = UDim.new(0, 2) BoxCorner.Parent = data.Box local BoxStroke = Instance.new("UIStroke") BoxStroke.Color = Color3.fromRGB(255, 255, 255) BoxStroke.Thickness = 2 BoxStroke.Transparency = 0.5 BoxStroke.Parent = data.Box -- Distance text data.DistanceLabel = Instance.new("TextLabel") data.DistanceLabel.Size = UDim2.new(1, 4, 0, 20) data.DistanceLabel.Position = UDim2.new(0.5, 0, 0, -25) data.DistanceLabel.BackgroundTransparency = 1 data.DistanceLabel.Text = "" data.DistanceLabel.TextColor3 = ESP_CONFIG.DISTANCE_COLOR data.DistanceLabel.TextScaled = true data.DistanceLabel.Font = Enum.Font.GothamBold data.DistanceLabel.TextStrokeTransparency = 0 data.DistanceLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0) data.DistanceLabel.Parent = data.Box -- Player name text data.NameLabel = Instance.new("TextLabel") data.NameLabel.Size = UDim2.new(1, 4, 0, 18) data.NameLabel.Position = UDim2.new(0.5, 0, 1, 2) data.NameLabel.BackgroundTransparency = 1 data.NameLabel.Text = player.Name data.NameLabel.TextColor3 = ESP_CONFIG.TEXT_COLOR data.NameLabel.TextScaled = true data.NameLabel.Font = Enum.Font.Gotham data.NameLabel.TextStrokeTransparency = 0 data.NameLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0) data.NameLabel.Parent = data.Box ESP_DATA[player] = data end -- Remove ESP for a player local function removeESP(player) if ESP_DATA[player] then for _, child in pairs(ESP_DATA[player]:GetChildren()) do child:Destroy() end ESP_DATA[player].Box:Destroy() ESP_DATA[player] = nil end end -- Update ESP position and visibility local function updateESP() for player, data in pairs(ESP_DATA) do if player.Parent and player.Character and player.Character:FindFirstChild("HumanoidRootPart") and player.Character:FindFirstChild("Humanoid") then local character = player.Character local humanoidRootPart = character.HumanoidRootPart local humanoid = character.Humanoid -- Check if player is alive if humanoid.Health > 0 then -- Convert 3D position to 2D screen position local screenPoint, onScreen = Camera:WorldToViewportPoint(humanoidRootPart.Position) if onScreen then -- Calculate distance local distance = math.floor((LocalPlayer.Character.HumanoidRootPart.Position - humanoidRootPart.Position).Magnitude) -- Get character size local head = character:FindFirstChild("Head") local sizeY = head and head.Size.Y or 2 local sizeX = sizeY * 0.5 -- Calculate box size based on distance local boxWidth = math.clamp(2000 / distance, 800, 3000) local boxHeight = boxWidth * 1.8 -- Position and size box data.Box.Size = UDim2.new(0, boxWidth, 0, boxHeight) data.Box.Position = UDim2.new(0, screenPoint.X - boxWidth/2, 0, screenPoint.Y - boxHeight/2) -- Update distance text data.DistanceLabel.Text = distance .. " studs" -- Fade based on distance local alpha = math.clamp(1 - (distance / 1000), 0.3, 1) data.Box.BackgroundTransparency = 1 - alpha * ESP_CONFIG.BOX_TRANSPARENCY data.BoxStroke.Transparency = 1 - alpha * 0.5 data.DistanceLabel.TextTransparency = 1 - alpha data.NameLabel.TextTransparency = 1 - alpha data.Box.Visible = true else data.Box.Visible = false end else data.Box.Visible = false end else data.Box.Visible = false end end end -- Handle player joining local function onPlayerAdded(player) player.CharacterAdded:Connect(function() wait(1) -- Wait for character to fully load createESP(player) end) -- Create ESP for existing character if player.Character then createESP(player) end end -- Handle player leaving local function onPlayerRemoving(player) removeESP(player) end -- Initialize ESP for all players for _, player in pairs(Players:GetPlayers()) do if player ~= LocalPlayer then onPlayerAdded(player) end end -- Connect events Players.PlayerAdded:Connect(onPlayerAdded) Players.PlayerRemoving:Connect(onPlayerRemoving) -- Update loop RunService.Heartbeat:Connect(updateESP) -- Toggle keybind (optional - Press 'E' to toggle ESP) local espEnabled = true UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.E then espEnabled = not espEnabled ScreenGui.Enabled = espEnabled for _, data in pairs(ESP_DATA) do data.Box.Visible = espEnabled end end end) print("ESP GUI Loaded! Press 'E' to toggle on/off")