Player Outline Tutorial

OUTLINE ON PLAYER

have u ever trying to add outlines on your character in your game but it wont work, it actually pretty easy!

  • Step 1: Add Server Script inside ServerScriptService
    Screenshot 2026-04-28 182429

  • Step 2: Add Player Services

local Players = game:GetService("Players")
  • Step 3: Add this below Players
Players.PlayerAdded:Connect(function(player) -- Get player
	player.CharacterAdded:Connect(function(character) -- Get Character
	end)
end)

all this does is getting the player character

  • Step 4: Add this inside Below the Player.CharacterAdded
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Highlight = Instance.new("Highlight")
		Highlight.Parent = character
	end)
end)

This will give the player the normal highlight effect, we need to change its property

  • Step 4: Setting the highlight property
    we have 2 option, the first one is the normal and the easy one:
Highlight.DepthMode = Enum.HighlightDepthMode.Occluded;
Highlight.Enabled = true;
Highlight.FillColor = Color3.fromRGB(0,0,0);
Highlight.FillTransparency = 1;
Highlight.Name = "Outline";
Highlight.OutlineColor = Color3.fromRGB(0,0,0);
Highlight.OutlineTransparency = 0

or the 2nd option which is the table one like this:

-- Put this above the Player service

local Outline_Prop = {
	DepthMode = Enum.HighlightDepthMode.Occluded;
	Enabled = true;
	FillColor = Color3.fromRGB(0,0,0);
	FillTransparency = 1;
	Name = "Outline";
	OutlineColor = Color3.fromRGB(0,0,0);
	OutlineTransparency = 0
}

for this option u need to put this below the highlight variable

for val, prop in pairs(Outline_Prop) do
	Highlight[val] = prop
end

This should the full script:

local Players = game:GetService("Players")

local Outline_Prop = {
	DepthMode = Enum.HighlightDepthMode.Occluded;
	Enabled = true;
	FillColor = Color3.fromRGB(0,0,0);
	FillTransparency = 1;
	Name = "Outline";
	OutlineColor = Color3.fromRGB(0,0,0);
	OutlineTransparency = 0
}

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Highlight = Instance.new("Highlight")
		Highlight.Parent = character
		for val, prop in pairs(Outline_Prop) do
			Highlight[val] = prop
		end
	end)
end)

and there you have it, a outline

10 Likes

Or you can just work smarter and not harder by adding one model with an highlight in it and make the player characters be in the model…

7 Likes

Yeah no this method is pretty bad.

as @COCOLEBAUJU73 said, you can just create a parent model for all characters and put them under it.

If your game also uses highlights in other places and you end up having more than 33 active for whatever reason, then older ones (or newer ones) just won’t render, which is why creating one per character is pretty bad.
Correction, the limit is now 255. Still bad practice to be creating one highlight per-character because each highlight adds an additional drawcall which is something you’d preferably want to avoid.

It’d probably also be better to create the highlight on the individual clients, as its not something the server needs at all.

5 Likes

yeah or make your highlight and (even though its not what it’s for) put it in starter character scripts, i think, as they get put as children of the character? Correct me if im wrong

1 Like

I’m not sure why everybody is suggesting moving all characters under a single model, that sounds like pretty bad practice given that a lot of scripts expect characters to always be under workspace.

The limit for highlights is 255, so unless you have massive servers, this isn’t an issue. I think OP’s method is the most practical.

3 Likes

Even that is more efficient than scripting them in at runtime.
(still dont do this please highlights can cause lag and have a limit)

2 Likes

Because you are supposed to make your own scripts?

Like yes if you use toolbox it is a bad practice but lets be real if you use the toolbox you cant really complain about everything not being compatible. . .

Edit: NO the limit of highlights is not 255 if only. . .

1 Like

The highlight limit was raised to 255 pretty recently. Lights, Camera, More Highlights! (for some reason Google says its 31 still)

I believe this resource was made just for convenience sake and not with optimisations in mind (or OP may have not realised this was an alternate route at the time).

Some games may also just rely on characters simply sitting in workspace directly and not under a model in workspace.

This is an alright resource for small games (like small server sizes) but it can be improved like you and some others suggested.

2 Likes

The limit is 255, it’s in the documentation: https://create.roblox.com/docs/reference/engine/classes/Highlight

Not all code has to come from the toolbox, you’re suggesting a level of code purity that doesn’t really help anyone…

1 Like

Was this announced anywhere? Because I cannot recall anything like it being mentioned outside of this thread.

Edit: I didn’t pay much attention and the blue of the link was hardly visible on my screen…

Optimization is something every single developer should consider and the 255 limit is pretty new, you can ask a developers I can bet a good portion won’t know it got updated.

Bad practice is designing your code or using scripts that fetch a player’s character by searching/indexing Workspace and not by indexing Player.Character. That’s just asking for a whole load of bugs to happen the moment someone joins your game with a username that matches the name of something else already present in workspace.

The moment that happens you’re dealing with fun issues like that player being immortal or their presence breaking your entire game loop depending on where this logic is being executed.

4 Likes

Exactly. Using workspace:FindFirstChild(player.Name) is a recipe for disaster if there’s a part or model with the same name. Just use player.Character and avoid the unnecessary lookup entirely.

2 Likes

Or you could just add a highlight in StarterCharacterScripts!

1 Like

That works, but it’s pretty rigid. It’s fine for a simple outline, but you lose all control if you want to toggle it or change the color dynamically based on game state without more scripting anyway.

U actually can’t, if u do it will only visible to yourself not other. if u want it client side tho

That is not how replication works. If the Highlight is created on the server, it replicates to everyone. It only stays client-side if you specifically instantiate it in a LocalScript.

Nice method, however for better performance, i’d suggest adding a Cache [Folder] whenever the player leaves or dies, to prevent Destroying and cloning, very easy to handle

i’m pretty sure startercharacterscripts is serversided

No? Replication is a thing buddy.