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
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.
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
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
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