Script wont highlight player who are friends with each other

Code:

local player = game.Players.LocalPlayer

while wait() do

	for _, currentplayer in pairs(game.Players:GetPlayers()) do
		
		if not currentplayer.UserId == player.UserId then
			
			if player:IsFriendsWith(currentplayer.UserId) then

				if not currentplayer.Character:FindFirstChild("Highlight") then
					
					local Highlight = Instance.new("Highlight")
					Highlight.Parent = currentplayer.Character
					
					Highlight.DepthMode = Enum.HighlightDepthMode.Occluded
					
					Highlight.FillTransparency = 1
					
					Highlight.OutlineColor = Color3.fromRGB(76, 229, 0)
					
				end
				
			else
				
				if currentplayer.Character:FindFirstChild("Highlight") then

					currentplayer.Character:FindFirstChild("Highlight"):Destroy()

				end

			end
			
		end

	end

end

I want players who are friends with other players to have the other players highlighted. The script above doesnt show any error and doesnt work

2 Likes

I believe the Highlight instance is implemented but not released yet…

1 Like

but wat if they unfriend each other mid game?

1 Like

no it has been fully released actually

1 Like

Oh thnx for the info (char limit)

2 Likes

so how do i add the highlight effect to the players

1 Like

Set the FillTransparency to .5. Should fix ur issue

1 Like

but the color is the outline color not the fill

1 Like

Did you try setting the OutlineTransparency to smth lik .5 or 0?

1 Like

no i only set the fill transparency

1 Like

sorry for my reply it was wrong and realized it when i reread your code, but i’m assuming this is a bug so use selectionbox instead of highlight

2 Likes

https://developer.roblox.com/en-us/api-reference/class/Highlight

1 Like

well i have actually used the highlight feature before and it worked

1 Like
local Game = game
local Players = Game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		local Success, Result = pcall(function() return LocalPlayer:IsFriendsWith(Player) end)
		if not Success then warn(Result) return end
		if not Result then return end
		local Highlight = Instance.new("Highlight")
		Highlight.Adornee = Character
		Highlight.Parent = Character
	end
	
	local Character = Player.Character
	if Character then OnCharacterAdded(Character) else Player.CharacterAdded:Connect(OnCharacterAdded) end
end

Players.PlayerAdded:Connect(OnPlayerAdded)
1 Like