How do i make enemy highlights for each player?

How do i make enemy highlights for each player?

Example:

Your on red team. Your teammate(s) are highlighted green

Your on red team. Your enemy(s) are highlighted red


Your on blue team. Your teammate(s) are highlighted green

Your on blue team. Your enemy(s) are highlighted red

With the arrivial of the Highlight instance, im very, very VERY unsure how to create this type of effect.

2 Likes

Make a local script that makes highlights for every player. You will need some sort of system to tell the client in which team the person is. Then just set the colour of that highlight to what it’s supposed to actually be. Because it’s only a visual, you shouldn’t actually create these highlights on the Server. If you want to know how to use highlights, just parent them to a part and then set the adornee property to that part, after that it will show up.

LocalScript, StarterCharacterScripts or StarterPlayerScripts

local Players = game:GetService("Players")

local function RefreshHighlights()
	for i, Player in pairs(Players:GetPlayers()) do
		if Player ~= Players.LocalPlayer then
			local Character = Player.Character

			if Character then
				if Character:FindFirstChildWhichIsA("Highlight") then
					Character:FindFirstChildWhichIsA("Highlight"):Destroy()
				end

				if Player.Team ~= Players.LocalPlayer.Team then
					local Highlight = Instance.new("Highlight")
					Highlight.FillColor = Color3.new(1)
					Highlight.Parent = Character
				else
					local Highlight = Instance.new("Highlight")
					Highlight.FillColor = Color3.new(0, 1)
					Highlight.Parent = Character
				end
			end
		end
	end
end
How to use highlight function thingy

Use a loop

while task.wait(1) do
	RefreshHighlights()
end

or RunService

local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	RefreshHighlights()
end)

edit: it works

Screenshot 2022-07-22 192722

Where do i put

these scripts?`

Whatever solution you decide to take, be careful! You can only highlight up to 31 parts (If put under a model every part in the model counts).

With R6 there are:

  1. HumanoidRootPart
  2. LeftArm
  3. RightArm
  4. Head
  5. Torso
  6. LeftLeg
  7. RightLeg

+ Extra assets like hats/glasses etc...

Those at the bare minimum are already 7 parts per player.

1 Like

I thought you can highlight 31 parts

1 Like

I am sorry, I got confused for a second.