Proximity Prompt Triggered not working

my Proximity Prompt Trigger event is not working on Custom ProximityPrompt UI does anyone know what the issue is?

this is my code

for i,v in pairs(workspace.Plants:GetDescendants()) do
	if v:IsA("ProximityPrompt") then
		if v.Style == Enum.ProximityPromptStyle.Custom then
			v.Triggered:Connect(function(plr)
				print("Triggered")
			end)
		end
	end
end

for i,v:ProximityPrompt in pairs(workspace.NPCs:GetDescendants()) do
	if v:IsA("ProximityPrompt") then
		print(v.Name,v.Parent.Name)
		if v.Style == Enum.ProximityPromptStyle.Custom then
			v.Triggered:Connect(function(plr)
				print("Triggered2")
			end)
		end
	end
end

the script doesn’t print anything when i pressed the keycode

Maybe switch the v.Triggered and v.Style checks.

I’m not sure if this was the problem, but I think… v:ProximityPrompt will not work work because I thought that the : operator would type check v, not class check. It’s probably part of the for pairs loop, but I’ve never seen it before…

Just fix that line and remove the :ProximityPrompt part or use this provided script as the updated version…

for i,v in pairs(workspace.Plants:GetDescendants()) do
	if v:IsA("ProximityPrompt") then
		if v.Style == Enum.ProximityPromptStyle.Custom then
			v.Triggered:Connect(function(plr)
				print("Triggered")
			end)
		end
	end
end

for i, ProximityPrompt in pairs(workspace.NPCs:GetDescendants()) do
	if v:IsA("ProximityPrompt") then
		print(v.Name,v.Parent.Name)
		if v.Style == Enum.ProximityPromptStyle.Custom then
			v.Triggered:Connect(function(plr)
				print("Triggered2")
			end)
		end
	end
end

If it’s still not working for one or the other then try printing the ProximityPrompt Style, it could always be the wrong one.

didn’t work, i’ve tried removing the v.Style check and it still isn’t working

Is your custom prompt setup properly?

Can you class check like this? I thought : was used for type checking.

:ProximityPrompt is to set the value’s class so you can change/check the property of the class easily

yes, im pretty sure i did. i’ve made a script that creates a gui that appears once proximitypromptservice.PromptShown is triggered, the ProximityPrompt.Style is also Custom

even without the :ProximityPrompt the Plants proximityprompt should have triggered, but it didn’t

Where is this script located? it’s working for me tho

https://gyazo.com/577f01f47e3ff2c2898f2af3cfac8c43

(Sorry need to use gyazo OBS suffered at my workplace PC)

EDIT: I used the script you posted without edit anything

from what i see your using a localscript, but from what i know .Triggered or .PromptTriggered event should work on serverside

Yes it work that why i ask where did frame script located

EDIT: I mean the script

it’s located at serverscriptservice

Are you sure that it actually reached these code block?

is something print on this line?

and here i tested it again with serverside and it work as normal

1 Like

IsA is not gonna work in this instance; You’ll need to add the name of it:

for i,v in pairs(workspace.Plants:GetDescendants()) do
	if v.Name == "ProximityPrompt" then
		if v.Style == Enum.ProximityPromptStyle.Custom then
			v.Triggered:Connect(function(plr)
				print("Triggered")
			end)
		end
	end
end

for i,v:ProximityPrompt in pairs(workspace.NPCs:GetDescendants()) do
	if v:Name == "ProximityPrompt" then
		print(v.Name,v.Parent.Name)
		if v.Style == Enum.ProximityPromptStyle.Custom then
			v.Triggered:Connect(function(plr)
				print("Triggered2")
			end)
		end
	end
end

v.Triggered will work, your problem was IsA.

This worked completely fine for me:

for i, v in pairs(workspace:GetDescendants()) do
	
	if v:IsA("ProximityPrompt") then
		
		print("hello")
		
		v.Triggered:Connect(function(plr)
			
			print("triggered")
			
		end)
		
	end
	
end

After a few hours i found out the issue was on my spawning script, changing the primarypart cframe instead of using :SetPrimaryPartCFrame bugs the character out and making the client only move the primary part on the server which causes the proximityprompt not triggering when the client presses it. thanks for helping me trying to fix it though

3 Likes