ProximityPromptService

Show Deprecated
Service
Not Browsable

The ProximityPromptService allows developers to interact with ProximityPrompt objects in a global way. It may be more convenient to listen to events on this service rather than individual ProximityPrompt objects.

Summary

Properties

Whether ProximityPrompts are enabled, and therefore shown, in-game.

The maximum number of ProximityPrompts that will be shown to the user.

Methods

Events

PromptButtonHoldBegan(prompt: ProximityPrompt, playerWhoTriggered: Player): RBXScriptSignal  

Triggers when the player begins holding down the key/button on a prompt with a non-zero ProximityPrompt.HoldDuration.

PromptButtonHoldEnded(prompt: ProximityPrompt, playerWhoTriggered: Player): RBXScriptSignal  

Triggers when the user stops holding down the key/button on a prompt with a non-zero ProximityPrompt.HoldDuration.


Triggers client-side when a prompt becomes hidden.


Triggers client-side when a prompt becomes visible.

PromptTriggerEnded(prompt: ProximityPrompt, playerWhoTriggered: Player): RBXScriptSignal  

Triggers when the player stops holding down the key/button while triggering a prompt.

PromptTriggered(prompt: ProximityPrompt, playerWhoTriggered: Player): RBXScriptSignal  

Triggers when the user interacts with this prompt.

Properties

Enabled

This property determines whether ProximityPrompts are enabled, and therefore shown, in-game. When false, no prompts will be shown.

For example, in a round based system developers could disable prompts at certain points in the game to disable proximity-based interactions.


-- Server Script 1
local ProximityPromptService = game:GetService("ProximityPromptService")
local enablePrompts = workspace.EnablePrompts -- BindableEvent
-- Connected to a BindableEvent that is fired by another script controlling game logic
enablePrompts.OnServerEvent:Connect(function(enabled)
ProximityPromptService.Enabled = enabled
end)

-- Server Script 2
local enablePrompts = workspace.EnablePrompts -- BindableEvent
-- Some game event
enablePrompts:FireServer(false) -- Disable
wait(5)
enablePrompts:FireServer(true) -- Re-enable

MaxPromptsVisible

This property indicates the maximum number of ProximityPrompts that will be shown to the user.

The code block below demonstrates how this limit would be applied:


local ProximityPromptService = game:GetService("ProximityPromptService")
ProximityPromptService.MaxPromptsVisible = 2 -- No more than 2 prompts will be shown to the user at any given time

Methods

Events

PromptButtonHoldBegan

This event triggers when the player begins holding down the key/button on a prompt with a non-zero ProximityPrompt.HoldDuration. This can be used to animate a progress bar.

Parameters

The prompt that the player begins interacting with.

playerWhoTriggered: Player

The player who holds the key/button.


PromptButtonHoldEnded

This event triggers when the user stops holding down the key/button on a prompt with a non-zero ProximityPrompt.HoldDuration. This can be used to animate a progress bar.

Parameters

The prompt that the player stops interacting with.

playerWhoTriggered: Player

The player who releases the held key/button.


PromptHidden

This event triggers client-side, in connected LocalScripts when a prompt becomes hidden.

Parameters

The prompt instance that becomes hidden.


PromptShown

This event triggers client-side, in connected LocalScripts, when a prompt becomes visible.

Parameters

The prompt instance that becomes visible.

The input that triggered the event.


PromptTriggerEnded

This event triggers when the player stops holding down the key/button while triggering a prompt. This is intended to allow interactions which require the player to hold a button while something happens in-game.

Parameters

The prompt that the players stops interacting with.

playerWhoTriggered: Player

The player that releases the key/button.


PromptTriggered

This event triggers when the player interacts with this prompt.

Parameters

The prompt that the players interacts with.

playerWhoTriggered: Player

The interacting player.