Advertisement
Cra-Z-Gaming

Roblox ESP W/ team color

Oct 2nd, 2024 (edited)
2,470
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | Gaming | 1 0
  1. -- Variables
  2. local players = game:GetService("Players")
  3. local localPlayer = players.LocalPlayer
  4. local camera = game:GetService("Workspace").CurrentCamera
  5. local runService = game:GetService("RunService")
  6.  
  7. -- Function to create the ESP box with team color
  8. local function createESPBox(player)
  9.     local highlight = Instance.new("Highlight")
  10.     highlight.Name = player.Name .. "_ESP"
  11.     highlight.Adornee = player.Character
  12.     highlight.FillTransparency = 1 -- Makes the fill of the box invisible
  13.    
  14.     -- Check if the player is on a team and apply the team color
  15.     if player.Team then
  16.         highlight.OutlineColor = player.Team.TeamColor.Color -- Set the box color to the team's color
  17.     else
  18.         highlight.OutlineColor = Color3.new(1, 1, 1) -- Default color (white) if not in a team
  19.     end
  20.    
  21.     highlight.OutlineTransparency = 0 -- Fully visible outline
  22.     highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop -- Can be seen through walls
  23.     highlight.Parent = player.Character
  24. end
  25.  
  26. -- Add ESP to all players
  27. local function addESP()
  28.     for _, player in pairs(players:GetPlayers()) do
  29.         if player ~= localPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  30.             -- Check if ESP already exists to avoid duplication
  31.             if not player.Character:FindFirstChild(player.Name .. "_ESP") then
  32.                 createESPBox(player)
  33.             end
  34.         end
  35.     end
  36. end
  37.  
  38. -- Run the ESP adding function continuously
  39. runService.RenderStepped:Connect(function()
  40.     addESP()
  41. end)
  42.  
  43. -- Remove ESP if a player leaves
  44. players.PlayerRemoving:Connect(function(player)
  45.     if player.Character and player.Character:FindFirstChild(player.Name .. "_ESP") then
  46.         player.Character[player.Name .. "_ESP"]:Destroy()
  47.     end
  48. end)
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement