Highlight not enabling correctly with Proximity Prompt

Hi,

I added a custom proximity prompt to my mesh. The prompt works as intended, but there’s a feature I’d like to add that’s not working properly for me.

When the proximity prompt is shown, it’s supposed to enable the highlight that’s inside the mesh, but it doesn’t activate correctly. When I run the game, the highlight is already showing, which is not supposed to happen. The highlight is only supposed to show when the prompt is showing.

What am I doing wrong?

image

This is the Prompt localscript inside StarterPlayerScripts:

local camera = workspace:WaitForChild("CameraMesh")
local prompt = camera:WaitForChild("ProximityPrompt")
local gui = camera:WaitForChild("Mesh_Prompt")
local highlight = camera:WaitForChild("Highlight")
local actionText = gui:WaitForChild("ActionText")
local keyInput = gui:WaitForChild("KeyInput")

highlight.OutlineTransparency = 1
highlight.Enabled = true
highlight.DepthMode = Enum.HighlightDepthMode.Occluded

prompt.PromptShown:Connect(function()
	gui.Enabled = true
	highlight.OutlineTransparency = 0
	actionText.Text = actionText.Text
end)

prompt.PromptHidden:Connect(function()
	gui.Enabled = false
	highlight.OutlineTransparency = 1
end)

keyInput.MouseButton1Click:Connect(function()
	prompt:InputBegan(game.Players.LocalPlayer)
end)

prompt.Triggered:Connect(function(player)
	print("it works!!")
end)
1 Like

First, can you show the properties of the Highlight?

Along with a video (if you want) of whats happening?

So you are first off starting off the highlight with .Enabled, which sets the higlight to enabled once the game starts making it already show. Adding .Enabled only when the Prompt is shown and …Enabled = false when the Prompt is Hidden only makes the highlight appear when the prompt is shown and hidden when its not shown

highlight.Enabled = false
prompt.PromptShown:Connect(function()
    highlight.Enabled = true
	gui.Enabled = true  
	highlight.OutlineTransparency = 0
	actionText.Text = actionText.Text
end)
prompt.PromptHidden:Connect(function()
    highlight.Enabled = false
	gui.Enabled = false
	highlight.OutlineTransparency = 1
end)

EDIT: It works, thanks! The issue i was having after that was caused by activation distance from the prompt it self. I was in range which is why the highlight was already enabled.

Nvm i believe I found the issue. When I’m further away from the prompt the highlight disables. It seems to be a distance issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.