Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- -- Store highlights for cleanup
- local highlights = {}
- -- Function to create highlight
- local function highlightPlayer(player)
- if player == LocalPlayer then return end
- player.CharacterAdded:Connect(function(char)
- local highlight = Instance.new("Highlight")
- highlight.FillColor = Color3.fromRGB(255, 100, 100) -- light red
- highlight.OutlineColor = Color3.new(1, 1, 1) -- white outline
- highlight.FillTransparency = 0.3
- highlight.OutlineTransparency = 0
- highlight.Adornee = char
- highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop -- shows through walls
- highlight.Parent = game.CoreGui -- put in CoreGui so it doesn't get deleted by scripts
- highlights[player] = highlight
- end)
- -- If character already exists
- if player.Character then
- local highlight = Instance.new("Highlight")
- highlight.FillColor = Color3.fromRGB(255, 100, 100)
- highlight.OutlineColor = Color3.new(1, 1, 1)
- highlight.FillTransparency = 0.3
- highlight.OutlineTransparency = 0
- highlight.Adornee = player.Character
- highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
- highlight.Parent = game.CoreGui
- highlights[player] = highlight
- end
- end
- -- Add to all current players
- for _, player in pairs(Players:GetPlayers()) do
- highlightPlayer(player)
- end
- -- Add to new players
- Players.PlayerAdded:Connect(function(player)
- highlightPlayer(player)
- end)
- -- Remove highlights on leave
- Players.PlayerRemoving:Connect(function(player)
- if highlights[player] then
- highlights[player]:Destroy()
- highlights[player] = nil
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement