Highlight not showing

I am trying to make doors that when a prompt shows, a highlight appears… Anyone can tell me why it doesn’t work?

First script
local Handle1CD = script.Parent.Handle1.Attachment.ProximityPrompt
local Handle2CD = script.Parent.Handle2.Attachment.ProximityPrompt
local Remote = script.Parent.EnableHighlight
local RemoteDisabler = script.Parent.DisableHighlight
local Funi = script.Parent.LocalScript

function Highlight(plr)
	Remote:FireClient(plr)
end

function HighlightDisabled(plr)
	RemoteDisabler:FireClient(plr)
end

Handle1CD.PromptShown:Connect(Highlight)
Handle2CD.PromptShown:Connect(Highlight)
Handle1CD.PromptHidden:Connect(HighlightDisabled)
Handle2CD.PromptHidden:Connect(HighlightDisabled)
Second script (its a local script)
local Remote1 = script.Parent.EnableHighlight
local Remote2 = script.Parent.DisableHighlight
local Highlight = script.Parent.SussyHighlight

Remote1.OnClientEvent:Connect(function(plr)
	Highlight.Enabled = true
end)

Remote2.OnClientEvent:Connect(function(plr)
	Highlight.Enabled = false
end)

I’ve tried with ClickDetectors but it also didn’t work.

Any help is appreciated!

1 Like

OnClientEvent only works for the server you have specified that the script is inside a local script. Also, since you are using a proximity prompt you don’t need to use a remote event.

1 Like

Oh ok, so i can just enable the highlight without a local script?

2 Likes

Or without the normal script which fires the remotes?

1 Like

I tried only making it only work on a local script and it still doesnt work

1 Like

I also tried without the local script, it didn’t work
The worst part is that there aren’t any error showing up…

1 Like
ProximityPrompt.Triggered:Connect(function(player)
	script.Parent.Highlight.Enabled = true
end)
1 Like

But i wanted to use ProximityShown, is it possible to do so?

1 Like

Should the highlight be shown to every player? If not, then you can just do that from the client script; you don’t need to use any remote events. The only time where you have to use remote event is anything that must be replicated to the server such buying items etc.

1 Like

No it won’t show to every player, just the one locally, kinda like the drawers in games such as apeirophobia and doors, the highlights only show to the player

1 Like

Then all you need is a client/local script, but it would be better to add some attributes or a specific name for that object so there is only a single script that creates a connection for every object that should be highlighted. Example:

for _, object: Instance in ipairs(workspace:GetDescendants()) do
	if object.Name:match("Specific Door") then
		local proximityPrompt = object:FindFirstChildOfClass("ProximityPrompt")
		local highlight = object:FindFirstChildOfClass("Highlight")

		proximityPrompt.PromptShown:Connect(function()
			highlight.Enabled = true
		end)

		proximityPrompt.PromptHidden:Connect(function()
			highlight.Enabled = false
		end)
	end
end
1 Like

Ok, i’ll try it right now! Thanks!

1 Like

This is my script now:


for _, object: Instance in ipairs(workspace:GetDescendants()) do
	if object.Name:match("DoorFun") then
		for i, door in ipairs(object:GetChildren()) do
			if door.Name:match("DoorModel") then
				local proximityPrompt1 = door.Handle1:FindFirstChildOfClass("Attachment"):FindFirstChildOfClass("ProximityPrompt")
				local proximityPrompt2 = door.Handle2:FindFirstChildOfClass("Attachment"):FindFirstChildOfClass("ProximityPrompt")
				local highlight = door:FindFirstChildOfClass("Highlight")

				proximityPrompt1.PromptShown:Connect(function()
					highlight.Enabled = true
				end)

				proximityPrompt1.PromptHidden:Connect(function()
					highlight.Enabled = false
				end)
				proximityPrompt2.PromptShown:Connect(function()
					highlight.Enabled = true
				end)

				proximityPrompt2.PromptHidden:Connect(function()
					highlight.Enabled = false
				end)
			end
		end
	end
end

And it still doesn’t work

1 Like

And yet there are still no error messages…

1 Like

Does it really have to have two proximity prompts? I made something similar, and it does work.

for _, object: Instance in ipairs(workspace:GetChildren()) do
	if not (object.Name == "Door") then continue end
	
	local proximityPromt = object:FindFirstChildOfClass("ProximityPrompt")
	local highlight = object:FindFirstChildOfClass("Highlight")
	
	proximityPromt.PromptShown:Connect(function()
		highlight.Enabled = true
	end)
	
	proximityPromt.PromptHidden:Connect(function()
		highlight.Enabled = false
	end)
end

1 Like

Yes it has, because i had to add attachments so the proximity prompts would actually show

I mean, i hope it doesn’t and that there’s a way to make the proximity prompt actually work without being put inside an attachment, that would’ve been helpful… Do you know a way on how to make the prompt appear on a model?

I think my studio has a problem: i made another part and placed the script, the highlight and the prompt inside it; the only thing that didn’t work was the highlight… or i’m just unlucky
Edit: i’m going to try in a new place
Edit 2: Also didn’t work, i think my studio is cursed

Was the script in StarterPlayerScripts? Because it worked when i put it there… that was stupid from me… i forgot that local scripts don’t run when they’re parented to a part or anything that isnt in the player in any way

2 Likes

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