function UpdatePlayerESP()
-- Loop through all players
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
pcall(function()
-- Skip the local player
if player == game.Players.LocalPlayer then
return
end
-- Ensure the player has a character with a Head
if player.Character and player.Character:FindFirstChild("Head") then
-- Check if the player already has a NameEsp
if not player.Character:FindFirstChild("NameEsp") then
-- Create the NameEsp if it doesn't exist
local nameEsp = Instance.new("BillboardGui", player.Character)
nameEsp.Name = "NameEsp"
nameEsp.ExtentsOffset = Vector3.new(0, 1, 0)
nameEsp.Size = UDim2.new(1, 200, 1, 30)
nameEsp.Adornee = player.Character.Head
nameEsp.AlwaysOnTop = true
local nameText = Instance.new("TextLabel", nameEsp)
nameText.Font = "GothamBold"
nameText.FontSize = "Size14"
nameText.TextWrapped = true
nameText.Size = UDim2.new(1, 0, 1, 0)
nameText.TextYAlignment = "Top"
nameText.BackgroundTransparency = 1
nameText.TextStrokeTransparency = 0.5
nameText.TextColor3 = Color3.fromRGB(255, 255, 255)
else
-- Update the distance text if NameEsp exists
local distance = (game:GetService("Players").LocalPlayer.Character.Head.Position - player.Character.Head.Position).Magnitude
player.Character.NameEsp.TextLabel.Text = player.Name .. " \n" .. math.round(distance) .. " Distance"
end
end
end)
end
end
-- Continuous loop to update ESP
while true do
UpdatePlayerESP()
wait(1)
end
To embed this project on your website, copy the following code and paste it into your website's HTML: