How to fix highlight player's script?

I have a script which is supposed to make other players highlighted on the clients screen, however I am receiving errors I can’t figure out, here’s my current script, please tell me if you find something wrong with it!

local plrs = {}
local players = game.Players:GetChildren()

for i, v in pairs(players) do
	table.insert(plrs, v.Name) 
end 

print(plrs)

game.Players.PlayerAdded:Connect(function(playa)
	table.insert(plrs, playa.Name)
	print(plrs)
end)

for i, v in pairs(plrs) do
	local target = game.Workspace:FindFirstChild(v)
	if target.Name ~= game.Players.LocalPlayer.Name then
		if target.Humanoid then
			if not target:FindFirstChild("Highlight") then
				local highlight = script.Highlight
				local hightlightc = highlight:Clone()
				highlight:Clone().Parent = target
			end
		end
	end
end

This part has no problem in itself

1st part of the code

The second part, however, I’m not sure.
is the “Highlight” object enabled, check the transparency

I didn’t find any other problem as of right now, I will update this if I find one

1 Like

It’s enabled and the transparency is at 0, however, when a put a print(v) after the local target = game.Workspace:FindFirstChild(v), it printed nil, so it has to be something with that.

I made it work!, I had to replace target with the plyer instead of the character, and then just do target.Character.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.