Class
ProximityPromptService
ServiceNotBrowsable
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#
Enabledboolean | Whether ProximityPrompts are enabled, and
therefore shown, in-experience.ReadSafe |
MaxIndicatorsVisibleint | Maximum number of prompt indicators that can be visible at once.ReadSafe |
MaxPromptsVisibleint | Maximum 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#
| IndicatorHidden | Triggers client-side when a prompt's indicator becomes hidden. |
| IndicatorShown | Triggers client-side when a prompt's indicator becomes visible. |
| PromptButtonHoldBegan | Triggers when the player begins holding down the
KeyboardKeyCode key/button on a
prompt with a non-zero HoldDuration. |
| PromptButtonHoldEnded | Triggers when the player stops holding down the
KeyboardKeyCode key/button on a
prompt with a non-zero HoldDuration. |
| PromptHidden | Triggers client-side when a prompt becomes hidden. |
| PromptShown | Triggers client-side when a prompt becomes visible. |
| PromptTriggered | Triggers when the user interacts with this prompt. |
| PromptTriggerEnded | Triggers 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.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The prompt that the player begins interacting with. | |
playerWhoTriggered | Player | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The prompt that the player stops interacting with. | |
playerWhoTriggered | Player | The player who releases the held key/button. |
PromptHidden(prompt: ProximityPrompt)#
This event triggers client-side in connected local scripts when a prompt becomes hidden.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The prompt instance that becomes hidden. |
PromptShown(prompt: ProximityPrompt, inputType: ProximityPromptInputType)#
This event triggers client-side in connected local scripts when a prompt becomes visible.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The prompt instance that becomes visible. | |
inputType | ProximityPromptInputType | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The prompt that the player interacts with. | |
playerWhoTriggered | Player | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
prompt | ProximityPrompt | The prompt that the player stops interacting with. | |
playerWhoTriggered | Player | The player that releases the key/button. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild