Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- -- Function to add a Highlight to a character
- local function addHighlightToCharacter(character)
- if not character:FindFirstChild("Highlight") then
- local highlight = Instance.new("Highlight")
- highlight.Parent = character
- highlight.FillColor = Color3.new(9, 9, 9) -- Red highlight
- highlight.OutlineColor = Color3.new(0, 1, 0) -- White outline
- end
- end
- -- Function to handle when a player's character is added
- local function handleCharacterAdded(character)
- addHighlightToCharacter(character)
- end
- -- Function to monitor new players
- local function handlePlayerAdded(player)
- -- Add highlight if the player's character already exists
- if player.Character then
- handleCharacterAdded(player.Character)
- end
- -- Connect to CharacterAdded for future character spawns
- player.CharacterAdded:Connect(handleCharacterAdded)
- end
- -- Connect existing players
- for _, player in pairs(Players:GetPlayers()) do
- if player ~= LocalPlayer then
- handlePlayerAdded(player)
- end
- end
- -- Connect new players
- Players.PlayerAdded:Connect(function(player)
- if player ~= LocalPlayer then
- handlePlayerAdded(player)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment