Extended Highlight

The Highlight effect is a pretty recent addition to Roblox Studio. It looks really awesome and has some useful properties that you may expect, such as an outline color and fill color property. Despite this, there is no MaxDistance render behavior you would expect from something like a BillboardGui. Instead, you can see Highlighter effects from miles away:

I put together this simple class called ExtendedHighlight to solve this issue.

The code is fairly simple, with a constructor and a couple getters/setters:

function ExtendedHighlight.new(maxDistance, highlight, parent)
	local extendedHighlight = setmetatable({}, ExtendedHighlight)
	
	extendedHighlight._maxDistance = maxDistance or DEFAULT_MAX_DISTANCE
	extendedHighlight._highlight = highlight
	
	if parent then
		highlight.Parent = parent
	end
	
	table.insert(highlighters, extendedHighlight)
	
	return extendedHighlight
end

It’s super easy to edit and add to if anyone wants. I created this because I feel like it’s a missing feature, but I expect Roblox will be adding it eventually. This is just for anyone that wants to use them.
The distance is calculated relative to the camera + This code is meant to be inside of a module. You are also meant to “inject” a highlighter instance to extend with the max distance behavior, but you can edit the code if you don’t like calling ExtendedHighlight.new() and Instance.new() back to back. And finally, if it wasn’t obvious to anyone already, this code can only be run on the client since we’re dealing with local camera positions.

Heres an example of what it might look like in code:

local ExtendedHighlight = require(script.ExtendedHighlight)

local dummy = workspace:WaitForChild("DummyA")

local highlight = Instance.new("Highlight")
highlight.OutlineColor = Color3.fromRGB()
highlight.FillColor = Color3.fromRGB()

-- in studs, of course
local maxDistance = 30
-- the parent property (third property) is not entirely necessary and just for shortcuts 
local extendedHighlight = ExtendedHighlight.new(maxDistance, highlight, dummy)
-- eg, you might wanna quickly create an extended highlight:
local otherHighlight = ExtendedHighlight.new(15, Instance.new("Highlight"), workspace.DummyB)

-- function calls
extendedHighlight:SetEnabled(false)
extendedHighlight:SetEnabled(true)
print(extendedHighlight:GetMaxDistance())
print(extendedHighlight:GetHighlight().Name)
extendedHighlight:Destroy()

The ExtendedHighlighter in action:

The nice thing about this piece of code is that its self contained and fairly optimized. I’m not sure how expensive it is to bind things to render step like this, but I don’t imagine it’s too computationally expensive.
Let me know if there are any bugs and I’ll edit the paste link with an updated version :slight_smile:

10 Likes

Seems like a neat module, but the name feels misleading. “Extended Highlight” sounds more like the highlight distance will be extended, but it could obviously also mean that the features are extended.

Nonetheless, good job!

3 Likes

It looks really good,may i know how you made the outline because for some reason the outline doenst show for my Highlight Instance

Thanks. What might you call it? I took the naming convention from a friend who called his extension of table (a module with various utility functions for tables) ExtendedTable.

Not sure, the name isn’t too bad. You could probably keep it, honestly.

Yes. Make sure OutlineTransparency is 0, Enabled set to true, and OutlineColor something easy to see. To get an outline all the way around a model, you should parent it directly to the model.

image

The default Highlight seems to be all red with a white outline.

it doesnt work,i only get to see the red on surface and the outline doesnt show no matter what transparency and all you said was true

Strange. Possibly a Studio bug? I have no issue rendering outlines with or without my code. They are fairly new instances, just out of Beta I believe, so they could be behaving oddly.

Edit: I noticed a bug in your console. Is that related to my module?

nope that error is from my plugins i guess its possible its studio bug or smth

It’s because of your graphical settings more than likely. Set to level21.