Roblox UtilitiesDevlHub Roblox Documentation

Class

ProximityPromptService

ServiceNotBrowsable
Inherits
Instance › Object
Memory category
Instances

Allows developers to interact with ProximityPrompt objects in a global way.

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

Properties 3#

EnabledbooleanWhether ProximityPrompts are enabled, and therefore shown, in-experience.ReadSafe
MaxIndicatorsVisibleintMaximum number of prompt indicators that can be visible at once.ReadSafe
MaxPromptsVisibleintMaximum number of ProximityPrompts that will be shown to the player.ReadSafe

Enabled: boolean#

ReadSafe

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

For example, in a round-based system, you can disable prompts at certain points in the experience to disable proximity-based interactions:

MaxIndicatorsVisible: int#

ReadSafe

This property sets the maximum number of prompt indicators that can be visible at the same time. Indicators are lightweight distance hints shown for ProximityPrompts when the player is within the prompt's MaxIndicatorDistance but still outside its MaxActivationDistance.

This property defaults to 16 and is clamped to the range [0, 64]. Because indicators are opt-in per prompt — a prompt's MaxIndicatorDistance defaults to 0, which disables its indicator — this property has no visible effect unless at least one prompt sets a non-zero MaxIndicatorDistance.

MaxPromptsVisible: int#

ReadSafe

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

Events 8#

IndicatorHiddenTriggers client-side when a prompt's indicator becomes hidden.
IndicatorShownTriggers client-side when a prompt's indicator becomes visible.
PromptButtonHoldBeganTriggers when the player begins holding down the KeyboardKeyCode key/button on a prompt with a non-zero HoldDuration.
PromptButtonHoldEndedTriggers when the player stops holding down the KeyboardKeyCode key/button on a prompt with a non-zero HoldDuration.
PromptHiddenTriggers client-side when a prompt becomes hidden.
PromptShownTriggers client-side when a prompt becomes visible.
PromptTriggeredTriggers when the user interacts with this prompt.
PromptTriggerEndedTriggers when the player stops holding down the KeyboardKeyCode key/button while triggering a prompt.

IndicatorHidden(prompt: ProximityPrompt)#

This event triggers client-side in connected local scripts when the indicator for a ProximityPrompt is no longer visible, such as when the player moves outside the prompt's MaxIndicatorDistance or the prompt is disabled. It is the counterpart to IndicatorShown and is convenient for tearing down custom indicator UI globally rather than connecting to each individual ProximityPrompt.

NameTypeDefaultDescription
promptProximityPromptThe prompt whose indicator becomes hidden.

IndicatorShown(prompt: ProximityPrompt)#

This event triggers client-side in connected local scripts when the indicator for a ProximityPrompt becomes visible, which happens when the player moves within the prompt's MaxIndicatorDistance but remains outside its MaxActivationDistance. Indicators are opt-in: a prompt only shows one when its MaxIndicatorDistance is set greater than 0 (the default of 0 disables the indicator). Listening on the service rather than on each ProximityPrompt is convenient when implementing custom indicator UI globally.

NameTypeDefaultDescription
promptProximityPromptThe prompt whose indicator becomes visible.

PromptButtonHoldBegan(prompt: ProximityPrompt, playerWhoTriggered: Player)#

This event triggers when the player begins holding down the KeyboardKeyCode key/button on a prompt with a non-zero HoldDuration.

NameTypeDefaultDescription
promptProximityPromptThe prompt that the player begins interacting with.
playerWhoTriggeredPlayerThe player who holds the key/button.

PromptButtonHoldEnded(prompt: ProximityPrompt, playerWhoTriggered: Player)#

This event triggers when the player stops holding down the KeyboardKeyCode key/button on a prompt with a non-zero HoldDuration.

NameTypeDefaultDescription
promptProximityPromptThe prompt that the player stops interacting with.
playerWhoTriggeredPlayerThe player who releases the held key/button.

PromptHidden(prompt: ProximityPrompt)#

This event triggers client-side in connected local scripts when a prompt becomes hidden.

NameTypeDefaultDescription
promptProximityPromptThe prompt instance that becomes hidden.

PromptShown(prompt: ProximityPrompt, inputType: ProximityPromptInputType)#

This event triggers client-side in connected local scripts when a prompt becomes visible.

NameTypeDefaultDescription
promptProximityPromptThe prompt instance that becomes visible.
inputTypeProximityPromptInputTypeThe input that triggered the event.

PromptTriggered(prompt: ProximityPrompt, playerWhoTriggered: Player)#

This event triggers when the player completes interaction with a prompt, either when the KeyboardKeyCode key/button is pressed, or after a specified amount of time holding the key/button if the prompt's HoldDuration is non-zero.

NameTypeDefaultDescription
promptProximityPromptThe prompt that the player interacts with.
playerWhoTriggeredPlayerThe interacting player.

PromptTriggerEnded(prompt: ProximityPrompt, playerWhoTriggered: Player)#

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

NameTypeDefaultDescription
promptProximityPromptThe prompt that the player stops interacting with.
playerWhoTriggeredPlayerThe player that releases the key/button.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed