Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Advertisement
Comments
-
- Do not use this shit in Bloodtide pls
-
- chatgpt ah script
Add Comment
Please, Sign In to add comment
Advertisement