0% found this document useful (0 votes)
2 views

message (4)

The document outlines a script for a Roblox game that allows players to toggle an ESP (Extra Sensory Perception) feature using a GUI button. It includes color customization for highlights, event connections for player additions and removals, and a keybind for toggling the GUI visibility. The script manages the addition and removal of highlights on player characters based on the ESP toggle state.

Uploaded by

chanseaiken
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)
2 views

message (4)

The document outlines a script for a Roblox game that allows players to toggle an ESP (Extra Sensory Perception) feature using a GUI button. It includes color customization for highlights, event connections for player additions and removals, and a keybind for toggling the GUI visibility. The script manages the addition and removal of highlights on player characters based on the ESP toggle state.

Uploaded by

chanseaiken
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/ 3

local colourTable = {

Green = Color3.fromRGB(0, 255, 0),


Blue = Color3.fromRGB(0, 0, 255),
Red = Color3.fromRGB(255, 0, 0),
Yellow = Color3.fromRGB(255, 255, 0),
Orange = Color3.fromRGB(255, 165, 0),
Purple = Color3.fromRGB(128, 0, 128)
}
local colourChosen = colourTable.Red -- Change "Red" to whatever colour you like
from the table above, feel free to add other colours as well.
_G.ESPToggle = false -- This is the variable used for enabling/disabling ESP. If
you are using a GUI library, or your own custom GUI, then set this variable to the
callback function.

-- Services and lp
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")

-- The following screen gui, frame and button creation may be deleted if you are
using a custom GUI library.
-- Create the screen gui
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "ESPToggleGui"
screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")

-- Create a frame
local mainFrame = Instance.new("Frame")
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(1, 0, 1, 0)
mainFrame.BackgroundTransparency = 1
mainFrame.Parent = screenGui

-- Create the button


local toggleButton = Instance.new("TextButton")
toggleButton.Name = "ToggleButton"
toggleButton.Size = UDim2.new(0, 200, 0, 50)
toggleButton.Position = UDim2.new(0.5, -100, 0.5, -25)
toggleButton.Text = "Toggle ESP"
toggleButton.Parent = mainFrame

local function getCharacter(player)


return Workspace:FindFirstChild(player.Name)
end

-- Add highlights to players


local function addHighlightToCharacter(player, character)
if player == LocalPlayer then return end -- Skip local player
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart and not humanoidRootPart:FindFirstChild("Highlight") then
local highlightClone = Instance.new("Highlight") -- Create a new Highlight
instance
highlightClone.Name = "Highlight"
highlightClone.Adornee = character
highlightClone.Parent = humanoidRootPart
highlightClone.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
highlightClone.FillColor = colourChosen
highlightClone.OutlineColor = Color3.fromRGB(255, 255, 255)
highlightClone.FillTransparency = 0.5
end
end

-- Remove highlights from player


local function removeHighlightFromCharacter(character)
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
local highlightInstance = humanoidRootPart:FindFirstChild("Highlight")
if highlightInstance then
highlightInstance:Destroy()
end
end
end

-- Function to update highlights based on the value of _G.ESPToggle


local function updateHighlights()
for _, player in pairs(Players:GetPlayers()) do
local character = getCharacter(player)
if character then
if _G.ESPToggle then
addHighlightToCharacter(player, character)
else
removeHighlightFromCharacter(character)
end
end
end
end

-- Connect events through RenderStepped to loop


RunService.RenderStepped:Connect(function()
updateHighlights()
end)

-- Add highlight to joining players


Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if _G.ESPToggle then
addHighlightToCharacter(player, character)
end
end)
end)

-- Remove highlights from leaving players


Players.PlayerRemoving:Connect(function(playerRemoved)
local character = playerRemoved.Character
if character then
removeHighlightFromCharacter(character)
end
end)

-- The following code may be deleted if you are using a custom GUI library.

-- Toggle ESP Button Text based on variable status


toggleButton.MouseButton1Click:Connect(function()
_G.ESPToggle = not _G.ESPToggle
if _G.ESPToggle then
toggleButton.Text = "ESP ON"
else
toggleButton.Text = "ESP OFF"
end
end)

-- Initial button text


if _G.ESPToggle then
toggleButton.Text = "ESP ON"
else
toggleButton.Text = "ESP OFF"
end

-- Keybind to toggle GUI visibility


UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.H and not gameProcessed then -- Change
Enum.KeyCode.H to another key if you want to, e.g. Enum.KeyCode.P for "P" Key.
mainFrame.Visible = not mainFrame.Visible
end
end)

You might also like