0% found this document useful (0 votes)
94 views2 pages

Esp

The document outlines a Lua script for a Roblox game that creates an ESP (Extra Sensory Perception) feature, allowing players to see other players' names and distances. It includes a toggle button GUI that enables or disables the ESP functionality, updating dynamically based on player positions. When activated, it creates a BillboardGui for each player, displaying their display name and distance from the local player.

Uploaded by

colt111808
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views2 pages

Esp

The document outlines a Lua script for a Roblox game that creates an ESP (Extra Sensory Perception) feature, allowing players to see other players' names and distances. It includes a toggle button GUI that enables or disables the ESP functionality, updating dynamically based on player positions. When activated, it creates a BillboardGui for each player, displaying their display name and distance from the local player.

Uploaded by

colt111808
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

-- Variables

local players = game:GetService("Players")


local localPlayer = players.LocalPlayer
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")

-- Create the Toggle Button GUI


local screenGui = Instance.new("ScreenGui", game.CoreGui)
local toggleButton = Instance.new("TextButton", screenGui)
toggleButton.Size = UDim2.new(0, 35, 0, 35)
toggleButton.Position = UDim2.new(0, 10, 0, 10)
toggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
toggleButton.Text = "ESP"
toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleButton.TextScaled = true

-- Variables to track the ESP state


local espEnabled = false
local espObjects = {}

-- Function to create ESP for a player


local function createESP(player)
if player == localPlayer then return end
local billboard = Instance.new("BillboardGui")
billboard.Adornee = nil
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.StudsOffset = Vector3.new(0, 3, 0)
billboard.AlwaysOnTop = true

local textLabel = Instance.new("TextLabel", billboard)


textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundTransparency = 1
textLabel.TextColor3 = Color3.new(1, 0, 0)
textLabel.TextStrokeTransparency = 0.5
textLabel.TextScaled = true
textLabel.Font = Enum.Font.SourceSansBold

-- Update ESP dynamically


local function updateESP()
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
local rootPart = character.HumanoidRootPart
local distance = (rootPart.Position -
localPlayer.Character.HumanoidRootPart.Position).Magnitude
billboard.Adornee = rootPart
textLabel.Text = string.format("%s (%s)\n%.1f studs",
player.DisplayName, player.Name, distance)
else
billboard.Adornee = nil
end
end

-- Add the BillboardGui to the player's character


local function onCharacterAdded(character)
local humanoidRootPart = character:WaitForChild("HumanoidRootPart", 5)
if humanoidRootPart then
billboard.Parent = humanoidRootPart
end
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

runService.RenderStepped:Connect(updateESP)
table.insert(espObjects, billboard)
end

-- Toggle ESP On/Off


toggleButton.MouseButton1Click:Connect(function()
espEnabled = not espEnabled
if espEnabled then
for _, player in pairs(players:GetPlayers()) do
createESP(player)
end
players.PlayerAdded:Connect(createESP)
toggleButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0) -- Green when
enabled
else
for _, espObj in pairs(espObjects) do
espObj:Destroy()
end
espObjects = {} -- Clear the ESP objects
toggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Red when
disabled
end
end)

-- Add ESP for all players when the script starts if ESP is enabled
if espEnabled then
for _, player in pairs(players:GetPlayers()) do
createESP(player)
end
players.PlayerAdded:Connect(createESP)
end

You might also like