Object "X-Ray/Highlighting" System


Hey everyone! I created the V1 of this module for a game I’m working on and it was refined by @GollyGreg on GitHub.

The source can be found here: https://github.com/Imaginaerume/rbx-ObjectHighlighter
Readme below V


This module allows you to make an object or model act as “Always on Top” (or X-Ray) and layer over the normal 3D game world.

Table of Contents


To provide an generic and extendable solution to adopting ViewportFrames as a means to render an object on top of a 3D environment.

This is intended to replace older solutions such as rbx-XRayAdornment. Our previous issues with this old xray module is that it made it really hard to balance the state of the target object with the actual rendering process.

There was some difficulty in making a good “only-render-when-obstructed” highlighted object. All attempts were messy and oddly coupled with the creation of the XRayAdornment itself.
Our philosophy is to separate highlight state from highlight render rules.


Implementations.highlightColor example

Implementations.worldColor example

Code Example

Check out our other annotated examples in the examples directory!

local ObjectHighlighter = require(ReplicatedStorage:FindFirstChild("ObjectHighlighter"))

-- This screen gui will contain our ViewportFrames
local myScreenGui = Instance.new("ScreenGui")
myScreenGui.Name = "ObjectHighlighter"
myScreenGui.Parent = Players.LocalPlayer.PlayerGui

local myRenderer = ObjectHighlighter.createRenderer(myScreenGui)

-- Assume we have a Model as a direct child of Workspace
local myHighlight = ObjectHighlighter.createFromTarget(Workspace.Model)

-- Apply our highlight object to our Renderer stack.
-- We can add as many highlight objects to a renderer as we need

	-- Our renderer will not render until it steps

Feel free to post here or DM me or @GollyGreg any questions, comments, issues or feedback :slight_smile:

Imaginaerum's Highlighting System w/ Example & Changes
[Request] How to make a player able to see other players through objects?

This is some next-level wallhacks. Lol

Great Resource!

Will probably be using it in my game for an ability.


Very nice! I considered doing this as well, but I’m very tired of creating ViewportFrame projects by now😅

I can see a lot of uses for this, and I hope lots of people use it!

I hope someone uses it to let you see your objective, like an object you have to go get. Would be dope.

All in all, great product! Kudos for sharing!


I see through the lies of this module!


That would actually be a pretty cool feature to add into one of my games.
Thanks for sharing!


Wow… This absolutely blew my mind. Great job with this, who knew X-ray would could be converted into ROBLOX, specially when it was made by the community itself.

Keep up the awesome work.:+1:


Saw a handful of people making these style setups when viewport frames where first being tested, really cool to see that you packaged your implementation up for distribution!

Although I’ll probably make my own it makes me happy to see someone release it for the community in such an accessible format so more games can enjoy the benefits. Great for creating games where you can see your team through walls (like L4D) and if asymmetric the “enemy” team can see players at all times.

Also solid for FPS style games where medics need to be able to see where low health team members are and doing a color-slide from orange-red as those team members lose more health.


This is GREAT for thermal scopes. Nice work!


Really impressed work! A lot of people could use this especially for people making FPS, or any kind of co-op game


I saw polyguns do this before viewport frames were a thing. How’d they pull it off?


CloneTrooper1019 did this as well for The Stalker 2. He open-sourced the code on Pastebin. What he did was replicate the characters to a Table and later placed them in the Camera and scaled and positioned them based on the character’s position relative to the camera’s CFrame. I could only make an educated guess that the developers of Polyguns did it in a fashion similar to this.


This looks exactly like Soldier 76’s ultimate in Overwatch haha, I like it!


I’m pretty sure they easily just inserted SurfaceGuis for each side of the character then made it AlwaysOnTop, since the models are all squares which is much more simpler.


I’ve been working with @Imaginaerum on the project to get it feature-ready for use in real games.

Features a new api, examples. Base code is the same, but reorganized. Read me has been upgraded.

Please fill out any Issues on the repository page if anything arises.


Very nice.

I plan on making a few demos of this just to play around, so I’ll be sure to post them here.
Thank you for your contribution to the community!


We should showcase demos on the project page if you ever have them hosted somewhere.


This is fun!

I made an extremely rough prototype of a “Digital Threat” scope, inspired by Apex Legends.

It checks if the object is within a GUI (the red dot gui) using WorldToScreenPoint, and then does a single raycast to check if the part is obscured.
If the part is in the gui and visible, it updates the highlight and makes it visible.

Plenty of bugs to work out here, but I wanted to show a cool usage idea.

Edit: Forgot to include my code :man_facepalming:t2:

		onBeforeRender = function(_, _)
			return true

		onRender = function(_, worldPart, viewportPart, highlight)
			--Only update within frame
			local v,oS	= Cam:WorldToScreenPoint(worldPart.CFrame.Position)
			if oS and insideGUI(v, gui) then
				--Only update if not obscured
				local blockingPart = workspace:FindPartOnRay(Ray.new(Cam.CFrame.Position,(worldPart.CFrame.Position - Cam.CFrame.Position).unit * 500), Cam)
				if blockingPart and not blockingPart:IsDescendantOf(worldPart.Parent) then
					viewportPart.Transparency	= 1
					viewportPart.Transparency	= worldPart.Transparency
					viewportPart.CFrame			= worldPart.CFrame
					viewportPart.Color			= highlight.color
				--not within gui
				viewportPart.Transparency = 1

		onAdded = function(_, viewportPart, highlight)
			local function clearTextures(instance)
				if instance:IsA("MeshPart") then
					instance.TextureID = ""
				elseif instance:IsA("UnionOperation") then
					instance.UsePartColor = true
				elseif instance:IsA("SpecialMesh") then
					instance.TextureId = ""

			local function colorObject(instance)
				if instance:IsA("BasePart") then
					instance.Color = highlight.color

			for _, object in pairs(viewportPart:GetDescendants()) do


That’s actually sick dude! Nice to know I’m not the only one who creates things inspired from Apex Legends lol.


I actually replicated Bloodhound’s tactical ability using this; the Eye of the Allfather. That thing that momentarily reveals the location of nearby players at the time of the use.


That’s what I was going to do next but I guess you beat me to that one :stuck_out_tongue_winking_eye::yum: