Advertisement
HowToRoblox

PlayerHighlighter

Nov 9th, 2022 (edited)
1,879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. local client = game.Players.LocalPlayer
  2.  
  3. local configuration = {
  4.     USE_TEAM_COLOURS = true, --If this is enabled, player outlines will be based on team colours instead of the colours below
  5.    
  6.     ALLY_FILL_COLOUR = Color3.fromRGB(131, 212, 255), --Fill colour for allies
  7.     ALLY_FILL_TRANSPARENCY = 0.4, --Fill transparency for allies
  8.    
  9.     ALLY_OUTLINE_COLOUR = Color3.fromRGB(42, 163, 255), --Outline colour for allies
  10.     ALLY_OUTLINE_TRANSPARENCY = 0, --Outline transparency for allies
  11.    
  12.    
  13.     ENEMY_FILL_COLOUR = Color3.fromRGB(255, 82, 85), --Fill colour for enemies
  14.     ENEMY_FILL_TRANSPARENCY = 1, --Fill transparency for enemies
  15.  
  16.     ENEMY_OUTLINE_COLOUR = Color3.fromRGB(208, 32, 32), --Outline colour for enemies
  17.     ENEMY_OUTLINE_TRANSPARENCY = 0, --Outline transparency for enemies
  18. }
  19.  
  20.  
  21. function handleHighlight(highlightObject, plr)
  22.    
  23.     if plr.Team == client.Team then --This means the player is an ally
  24.        
  25.         highlightObject.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
  26.        
  27.         highlightObject.FillTransparency = configuration.ALLY_FILL_TRANSPARENCY
  28.         highlightObject.OutlineTransparency = configuration.ALLY_OUTLINE_TRANSPARENCY
  29.        
  30.         if configuration.USE_TEAM_COLOURS then
  31.             highlightObject.FillColor = plr.TeamColor.Color
  32.             highlightObject.OutlineColor = plr.TeamColor.Color
  33.            
  34.         else
  35.             highlightObject.FillColor = configuration.ALLY_FILL_COLOUR
  36.             highlightObject.OutlineColor = configuration.ALLY_OUTLINE_COLOUR
  37.         end
  38.        
  39.     else --This means the player is an enemy
  40.        
  41.         highlightObject.DepthMode = Enum.HighlightDepthMode.Occluded
  42.        
  43.         highlightObject.FillTransparency = configuration.ENEMY_FILL_TRANSPARENCY
  44.         highlightObject.OutlineTransparency = configuration.ENEMY_OUTLINE_TRANSPARENCY
  45.        
  46.         if configuration.USE_TEAM_COLOURS then
  47.             highlightObject.FillColor = plr.TeamColor.Color
  48.             highlightObject.OutlineColor = plr.TeamColor.Color
  49.  
  50.         else
  51.             highlightObject.FillColor = configuration.ENEMY_FILL_COLOUR
  52.             highlightObject.OutlineColor = configuration.ENEMY_OUTLINE_COLOUR
  53.         end
  54.     end
  55. end
  56.  
  57. function handleChar(plr)
  58.    
  59.     local char = plr.Character or plr.CharacterAdded:Wait()
  60.    
  61.     local highlightObject = plr.Character:FindFirstChild("TEAM HIGHLIGHTER") or Instance.new("Highlight")
  62.     highlightObject.Name = "TEAM HIGHLIGHTER"
  63.    
  64.     handleHighlight(highlightObject, plr)
  65.    
  66.     highlightObject.Parent = char
  67. end
  68.  
  69. function handlePlr(plr)
  70.    
  71.     if plr == client then return end
  72.    
  73.     if plr.Character then
  74.         handleChar(plr)
  75.     end
  76.    
  77.     plr.CharacterAdded:Connect(function(char)
  78.        
  79.         handleChar(plr)
  80.     end)
  81.    
  82.     plr:GetPropertyChangedSignal("Team"):Connect(function()
  83.        
  84.         handleChar(plr)
  85.     end)
  86. end
  87.  
  88.  
  89. game.Players.PlayerAdded:Connect(handlePlr)
  90.  
  91. for i, plr in pairs(game.Players:GetPlayers()) do
  92.    
  93.     handlePlr(plr)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement