Bounds Constrained Highlighter

Yes, I made another ViewportFrame thing. :stuck_out_tongue:

Before I begin…

Major shoutout to @Imaginaerum and @GollyGreg for making a wonderful highlighter library. I didn’t use it for this project, but it is what originally inspired me to make this. The library is absolutely fantastic, and it supports many usages. However, I needed a system optimized for this specific scenario. Go send them some love!

What is it?

This module allows you to highlight objects in an XRay fashion but only when visible within the bounds of a specified part. A bit hard to understand that, so it’s best I show you!

Inspired by Apex Legends, (the game that kills my productivity) this sight highlights the NPCs in the game.

You can use it for cool stuff like this enemy detector as well!

Notes:

I made this module really quickly, just for fun, and didn’t test beyond this base scenario shown here. Some of the code is actually untested. :grimacing::sweat_smile: I’m sure there are plenty of cases where it fails. Be sure to let me know of these!

API:

	------------------------------------------------------------------------------------
	Module API:
		
	function	BoundsHighlighter:Start()
		Description:
			Enables the highlighter
		Note:
			Cannot be called until a BoundsPart is set via :SetBoundsPart()
	
	
	function	BoundsHighlighter:Stop()
		Description:
			Disables the highlighter
		Note:
			None
		
			
	function	BoundsHighlighter:Render(Model)
		Description:
			Adds a model to the rendering process
		Note:
			Designed for standard Humanoids, so it wont do Parts inside of Parts
		
			
	function	BoundsHighlighter:AddToIgnoreList(Instance)
		Description:
			Adds an instance to the ignore list of the visibility checks
		Note:
			None
		
			
	function	BoundsHighlighter:SetBoundsPart(BasePart)
		Description:
			Sets the part that will be used to calculate the bounds
		Note:
			The parts Front face must be facing the camera (at least mostly)
			
			
	------------------------------------------------------------------------------------
	Example Usage:
		
	for i, npc in pairs(workspace.NPCs:GetChildren()) do
		BoundsHighlighter:Render(npc)
	end
	
	BoundsHighlighter:SetBoundsPart(FPSViewModel.Sight)
	BoundsHighlighter:AddToIgnoreList(FPSViewModel)
	
	BoundsHighlighter:Start()
	
	------------------------------------------------------------------------------------

Source:

Uncopylocked and Public Place:


GitHub:

Roblox Library:




Enjoying my work? I love to create and share with the community, for free.

I make loads of free and open source scripts and modules for you all to use in your projects!
You can find a lot of them listed for you in my portfolio. Enjoy!

If you’d like to help fund my work, check out my Patreon or PayPal!

42 Likes

Hey. Is there a way to use this without using an actual parts, but instead a GUI? (Meaning I won’t have to set a boundspart up, instead just specify a UI object).