Hello I’m dealing with proximity prompt , but I’m wandering how can I avoid two players trigger it at the same time . Can anyone help me ?
You can change the Exclusivity
to OneGlobally
to make sure that only one ProxmityPrompt
is being displayed globally, as such:
“ OneGlobally - If multiple proximity prompts are set to OneGlobally exclusivity, only one proximity prompt is visible at any given time, regardless of their proximity or keycode. The camera’s view direction determines which proximity prompt is visible. This is useful to minimize proximity prompt distraction when there are several in an area. “
But this is if a player wants a proximity prompt to be see only if pointed by the camera
Oh that’s my bad, I should’ve read the documentation. I thought it the Exclusivity
was for the amount of clients which can view the ProxmityPrompt
. Anyway I assume you want the ProxmityPrompt
to be disabled for other players once a single player is in the vicinity of the ProxmityPrompt
. But that requires some ‘hacky’ methods ( from my understanding of the ProxmityPrompt
system ). So instead you can use a ‘clicked’ variable within the .Triggered
function. As such:
local proxmityPrompt: ProxmityPrompt = script.Parent -- or where ever your proxmity prompt is
local promptTriggered: boolean = false :: boolean
proxmityPrompt.Triggered:Connect(function(playerWhoTriggered: Player)
if (promptTriggered :: boolean) then
return
end
promptTriggered = true :: boolean
end)
This code makes sure that the ProxmityPrompt
is only triggered once. If you wish to re-enable the ability to trigger the ProxmityPrompt
just set the promptTriggered
variable to false. As such:
promptTriggered = true :: boolean
I hope this helps