Class · inherits Instance
ProximityPrompt
An object that lets you prompt players to interact with an object in the 3D world.
About ProximityPrompt
The ProximityPrompt instance lets you prompt players to interact with an
object in the 3D world, such as opening a door or picking up an item. A
ProximityPrompt object works when parented to a BasePart,
Attachment, or Model (with
PrimaryPart set) in the workspace. When the player's
character approaches, a UI appears to prompt them for input.
Prompts consist of three primary elements, each of which can be controlled by
the noted properties. The default UI can be swapped out for your own custom
appearance as outlined in Style.
You can connect to proximity prompt events either on the
ProximityPrompt object itself or globally through
ProximityPromptService. The ProximityPromptService allows you
to manage all proximity prompt behavior from one location, preventing any need
for duplicate code in your experience.
For more information regarding proximity prompts, see the Proximity Prompts guide.
Properties 15
ActionText
: stringThe action text shown to the user.This property determines the action text shown to the user.
AutoLocalize
: booleanWhether the prompt'sProximityPrompt.ActionTextandProximityPrompt.ObjectTextwill be localized according to theProximityPrompt.RootLocalizationTable.This property determines whether the prompt's
ProximityPrompt.ActionTextandProximityPrompt.ObjectTextwill be localized according to theProximityPrompt.RootLocalizationTable. When set to true, localization will be applied.ClickablePrompt
: booleanWhether the prompt can be activated by clicking/tapping on the prompt UI.This property determines whether the prompt can be activated by clicking/tapping on the prompt's UI. When set to false, the prompt cannot be activated by click/tap except on mobile.
Enabled
: booleanWhether or not this prompt should be shown.This property indicates whether or this
ProximityPromptshould be shown.Exclusivity
: ProximityPromptExclusivityUsed to customize which prompts can be shown at the same time.This property is used to customize which prompts can be shown at the same time.
GamepadKeyCode
: KeyCodeThe gamepad button the player should press to trigger the prompt.This property determines the gamepad button the player should press to trigger the
ProximityPrompt. Default is ButtonX.HoldDuration
: floatThe duration, in seconds, that the player must hold the button/key down to trigger the prompt.This property indicates the duration, in seconds, that the player must hold the button/key down to trigger the prompt.
KeyboardKeyCode
: KeyCodeThe key the player should press to trigger the prompt.This property determines the key the player should press to trigger the
ProximityPrompt. Default is E.MaxActivationDistance
: floatThe maximum distance a Player'scharactercan be from theProximityPromptfor the prompt to appear.This property determines the maximum distance a Player's
charactercan be from theProximityPromptfor the prompt to appear.MaxIndicatorDistance
: floatThe maximum distance at which a lightweight indicator for the prompt is shown, hinting at a nearby interaction before the player is close enough to trigger it.The maximum distance a player's
charactercan be from theProximityPromptfor a lightweight indicator to appear. An indicator is shown while the player is farther thanProximityPrompt.MaxActivationDistancebut no farther than MaxIndicatorDistance, hinting that an interaction is nearby before the prompt itself becomes active.The default is
0, which disables the indicator; an indicator only appears when this property is set to a value greater than0. The number of indicators shown at once is capped byProximityPromptService.MaxIndicatorsVisible.ObjectText
: stringAn optional property that determines the object name text shown to the user.This optional property determines the optional object name text shown to the user.
RequiresLineOfSight
: booleanWhether the prompt is hidden if the path between the player'sCameraand object parented to theProximityPromptis obstructed.This property indicates whether the prompt is hidden if the path between the player's
Cameraand object parented to theProximityPromptis obstructed. If true, this prompt will only be shown if there is a clear path from the camera to the object.The parent
PartorModelof the prompt will be excluded from this check.RootLocalizationTable
: LocalizationTableA reference to aLocalizationTableto be used to apply automated localization to this prompt'sProximityPrompt.ActionTextandProximityPrompt.ObjectText.This property serves as a reference to the
LocalizationTableused to apply automated localization to the prompt'sProximityPrompt.ActionTextandProximityPrompt.ObjectText. In order for this to apply,ProximityPrompt.AutoLocalizemust be set.Developers can set this to reference a LocalizationTable anywhere in the
DataModel. It is not required to be a child ofLocalizationService. If there is no translation available in the referenced table it will look for a translation in the parent of that table, if it is also a LocalizationTable, and so on.Style
: ProximityPromptStyleThe style of the prompt's UI.This property indicates the prompt's style. When set to Custom, no default UI will be provided.
The provided UI can be swapped out for a custom UI. In order to do this, set Style to Custom. Then, listen to the
ProximityPrompt.PromptShownandProximityPrompt.PromptHiddenevents in aLocalScript, where developers should create and tear down the UI.Developers may also use
ProximityPrompt.PromptButtonHoldBeganandProximityPrompt.PromptButtonHoldEndedin order to utilize theProximityPrompt.HoldDurationprogress animation feature.UIOffset
: Vector2The pixel offset applied to the prompt's UI.This property indicates the pixel offset applied to the prompt's UI.
Methods 2
InputHoldBegin
() → ()Fires a signal indicating that the user began pressing the prompt GUI button.This function triggers a signal indicating that the user began pressing the
ProximityPromptprompt button. It should be used by developers who wish to customize the prompt and trigger it from a prompt GUI button press.InputHoldEnd
() → ()Fires a signal indicating that the user ended pressing the prompt GUI button.A counterpoint to
ProximityPrompt.InputHoldBegin, this signals that the user ended pressing the prompt GUI button.
Events 8
IndicatorHidden
ProximityPrompt.IndicatorHidden:Connect(function())Fires on the client when a lightweight indicator for the prompt is no longer shown.Fires client-side when a lightweight indicator for this
ProximityPromptis hidden, which occurs when the player'scharactermoves farther thanProximityPrompt.MaxIndicatorDistancefrom the prompt or the prompt itself becomes active. Use this event to tear down a custom indicator UI.As with
ProximityPrompt.IndicatorShown, indicators only appear whenProximityPrompt.MaxIndicatorDistanceis set to a value greater than0; it defaults to0.IndicatorShown
ProximityPrompt.IndicatorShown:Connect(function())Fires on the client when a lightweight indicator for the prompt becomes visible.Fires client-side when a lightweight indicator for this
ProximityPromptbecomes visible, which occurs when the player'scharacteris withinProximityPrompt.MaxIndicatorDistanceof the prompt but still farther away thanProximityPrompt.MaxActivationDistance. Listen to this event to render a custom indicator UI.Because
ProximityPrompt.MaxIndicatorDistancedefaults to0, indicators are disabled unless you set it to a value greater than0.PromptButtonHoldBegan
ProximityPrompt.PromptButtonHoldBegan:Connect(function(playerWhoTriggered))Triggered when a player begins holding down thekey/button connected to a prompt with a non-zeroProximityPrompt.HoldDuration.This event triggers when a player begins holding down the
key/button on a prompt with a non-zeroProximityPrompt.HoldDuration. One possible usage includes to animate a hold progress bar.PromptButtonHoldEnded
ProximityPrompt.PromptButtonHoldEnded:Connect(function(playerWhoTriggered))Triggers when the player ends holding down the button on a prompt with a non-zeroProximityPrompt.HoldDuration.This event triggers when the player ends holding down the button on a prompt with a non-zero
ProximityPrompt.HoldDuration. One possible usage includes to animate a hold progress bar.Triggered
ProximityPrompt.Triggered:Connect(function(playerWhoTriggered))Triggered when the promptkey/button is pressed, or after a specified amount of time holding the button, ifProximityPrompt.HoldDurationis used.This event is triggered when the prompt
key/button is pressed, or after a specified amount of time holding the button, ifProximityPrompt.HoldDurationis used.TriggerEnded
ProximityPrompt.TriggerEnded:Connect(function(playerWhoTriggered))Triggers whenkey/button is released, for longer events where the user is required to hold down the button.This event is triggered when the
key/button is released, for longer events where the user is required to hold down the button (e.g. heal another player over time.)
ProximityPrompt also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.