Hold to activate multiple proximity prompts?

I’m making a game where proximity prompts are prominent, and there are many items you need to click / press E.

I want to add a feature that allows the player to hold down E to activate all proximity prompts within range, probably through a loop or something.

Is there any way to achieve this?

There does not appear to be any native component of the ProximityPrompt instance or ProximityPromptService that can enable your desired behaviour. Mind you, this is not an impossible feature, but it would require a good deal of effort to develop a wrapper that intercepts callbacks for remote invocation

Try setting the Exclusivity property of the prompt to AlwaysShow. If that doesn’t work then you should just make your own as then it’s not possible.

1 Like

I decided this would be a fun exercise, so I developed it for you. There is more than one script contributing to this wrapper’s functionality, so I’ve published it all to GitHub:

https://github.com/Ziffixture/Roblox/tree/main/RemoteProximityPrompt


It’s largely seamless; you won’t be able to tell that it’s not a raw ProximityPrompt instance:

--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")


local Vendor                = ReplicatedStorage.Vendor
local RemoteProximityPrompt = require(Vendor.RemoteProximityPrompt)

local ProximityPrompt = RemoteProximityPrompt(script.Parent)



local function onTriggered(player: Player)
	print(`{player} triggered the ProximityPrompt!`)
end



ProximityPrompt.Triggered:Connect(onTriggered)

Except it comes with a new method:

image

And the RemoteProximityPrompt module allows you to invoke the ProximityPrompt anywhere:

You can only trigger ProximityPrompts who have been processed by RemoteProximityPrompt. At this stage, you can simply perform a search for all ProximityPrompts in the player’s immediate area, then attempt to trigger them.

I did my best to make this “perfect”, but I’m sure there are some edge cases I’ve yet to consider. I know for a fact I did not implement any protection against registering the same ProximityPrompt more than once, but I couldn’t be asked since it’s already 4:00 AM :smiling_face_with_tear:

3 Likes

Enum.ProximityPromptExclusivity.AlwaysShow seems a lil simpler…

This is extremely kind of you not only for me but the whole community, thanks a lot Ziffix! Tried this out an it worked flawlessly, genuine lifesaver.

1 Like

I wouldn’t have assumed that this would enable @AriefYangArif’s desired behaviour. Appears to me as more of a cosmetic configuration. Despite that, I fear this solution isn’t as scalable. You would have to bombard the user’s screen with input options while also using making frequent modifications to or a setting a one-time absurd MaxActivationDistance value.

Nonetheless, I encourage OP to consider that approach, as mine undoubtedly suffers from overhead. Such is the blight of abstraction

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