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.

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.

Methods

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.


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

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

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:


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

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.


Methods