Skip to content

Instantly share code, notes, and snippets.

@mvyasu
Last active May 31, 2025 09:52
Show Gist options
  • Select an option

  • Save mvyasu/fedb108cadd33678d1db55549bdb7d82 to your computer and use it in GitHub Desktop.

Select an option

Save mvyasu/fedb108cadd33678d1db55549bdb7d82 to your computer and use it in GitHub Desktop.
A very simple script that highlights objects with ProximityPrompts inside them.
--by @mvyasu
--June 2 2022
local ProximityPromptService = game:GetService("ProximityPromptService")
local Players = game:GetService("Players")
local highlightLookupDictionary = {}
ProximityPromptService.PromptShown:Connect(function(promptInstance)
if not highlightLookupDictionary[promptInstance] then
local highlightAdornee = promptInstance:FindFirstAncestorWhichIsA("BasePart") or promptInstance:FindFirstAncestorOfClass("Model")
local newHighlight = Instance.new("Highlight")
newHighlight.DepthMode = Enum.HighlightDepthMode.Occluded
newHighlight.FillColor = Color3.fromRGB(230, 230, 230)
newHighlight.FillTransparency = 0.75
newHighlight.Adornee = highlightAdornee
newHighlight.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
highlightLookupDictionary[promptInstance] = newHighlight
end
end)
ProximityPromptService.PromptHidden:Connect(function(promptInstance)
local proximityPromptHighlight = highlightLookupDictionary[promptInstance]
if proximityPromptHighlight then
highlightLookupDictionary[promptInstance] = nil
proximityPromptHighlight:Destroy()
end
end)
@mvyasu
Copy link
Author

mvyasu commented Jan 23, 2023

There's an alternative way of doing this that's more simple. There was a reason why I didn't use this way in the video, but that reason is no longer relevant:

--by @mvyasu
--January 22 2023

local ProximityPromptService = game:GetService("ProximityPromptService")
local Players = game:GetService("Players")

ProximityPromptService.PromptShown:Connect(function(proximityPrompt)
	local highlightAdornee = proximityPrompt:FindFirstAncestorWhichIsA("PVInstance")

	local newHighlight = Instance.new("Highlight")
	newHighlight.DepthMode = Enum.HighlightDepthMode.Occluded
	newHighlight.FillColor = Color3.fromRGB(230, 230, 230)
	newHighlight.FillTransparency = 0.75
	newHighlight.Adornee = highlightAdornee
	newHighlight.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")

	proximityPrompt.PromptHidden:Once(function()
		newHighlight:Destroy()
	end)
end)

@DevLiamSite
Copy link

very helpful

@cxsorious
Copy link

Help add more commands. With the item in hand, Highlight disappeared. :) Thx

@ElectroModeYT
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment