Issues with ProximityPromptService "PromptTriggered" event not firing

Hi, so I’m having issues with proximityprompts in the system I’m making.

Basically, the “PromptTriggered” event doesn’t fire when it should, but only for the proximityprompts that I clone during runtime (meaning any prompts that I create before playtesting work fine).

This is an issue, because in my system the prompt gets cloned to the parent I want to interact with. Any help is appreciated.

1 Like

Please post your code, especially dealing with cloning and connecting to the PromptTriggered event!

It’s possible you’re cloning the ProximityPrompts from a client script, which will not be visible to the server. So if you’re listening to PromptTriggered from a server script, it will never fire for objects that exist only on the client.

If that’s the case, you need to either:

  1. Clone on the server instead
  2. Listen from the client instead

If you opt for #2, you could fire a remote event to the server letting them know the user interacted with the prompt.n Depending on the sensitivity of the response to triggering the prompt, you might consider adding a debounce (you might need it to be specific to each player) and doing a distance check on the server to make sure that the user is actually within proximity of a reasonable location that they could trigger a prompt from, since exploiters can fire that remote whenever they want.

1 Like

Oh, I never thought of that. Yes, I’m cloning the prompts from a local script and checking from the server. Would listening to the events being triggered on the client instead of the server fix the issue?

You can do it either way.

  1. Handle ProximityPrompts on the server, tell the server to clone the prompt.
  2. Handle ProximityPrompts on the client, request to the server what you need.

Number 1 would probably be the easiest option as it’s intended usage, especially when working with server data, but number 2 can be used to use client resources for connecting prompts and logic for any non-server related data, like showing a UI.

I think I’ll handle it on the client and whenever it’s triggered send it over to the server to verify some info and do what it needs to do.

If you dont mind, I have another question:
If I add a debounce on the server side of this system (so that players don’t spam interact), and multiple players interact with the same thing, would the debounce stop the other player or no? And if not, what would be a good fix?

The answer depends on what type of debounce you are using, and that is something you have to ask yourself if you need it.

-- debounce that affects all players
local canTrigger = true

prompt.Triggered:Connect(function(player)
    if canTrigger == false then
        return
    end

    canTrigger = false
    print(player.Name, "triggered the prompt")
    task.wait(1)
    canTrigger = false
end)

-- debounce that affects individual players
local triggers = {}

prompt.Triggered:Connect(function(player)
    if triggers[player] == true then
        return
    end

    triggers[player] = true
    print(player.Name, "triggered the prompt")
    task.wait(1)
    -- we set to nil to avoid memory leaks if the player leaves
    triggers[player] = nil
end)

Yeah I think I’ll affect all players with the debounce, since for example when opening drawers I don’t want the animation to overlap since that would cause issues.
Thanks for the help!

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