Reference API Roblox

Engine API

Website

Related

Reference API Roblox

ProximityPrompt

An object that lets you prompt players to interact with an object in the 3D world.

Member index 26

HistoryMember
553ActionText: string
553AutoLocalize: bool
553ClickablePrompt: bool
553Enabled: bool
553Exclusivity: ProximityPromptExclusivity
553GamepadKeyCode: KeyCode
553HoldDuration: float
553KeyboardKeyCode: KeyCode
553MaxActivationDistance: float
486ObjectText: string
553RequiresLineOfSight: bool
553RootLocalizationTable: LocalizationTable
553Style: ProximityPromptStyle
553UIOffset: Vector2
573InputHoldBegin(): null
573InputHoldEnd(): null
483PromptButtonHoldBegan(playerWhoTriggered: Player)
483PromptButtonHoldEnded(playerWhoTriggered: Player)
462PromptHidden()
462PromptShown(inputType: ProximityPromptInputType)
483TriggerEnded(playerWhoTriggered: Player)
483Triggered(playerWhoTriggered: Player)
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

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.

PropertyDescriptionDefault
ObjectTextAn optional name for the object being interacted with.
ActionTextAn optional action name shown to the player.Interact
KeyboardKeyCodeThe keyboard key which will trigger the prompt.E
GamepadKeyCodeThe gamepad button which will trigger the prompt.ButtonX

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.

History 84

Members 26

ActionText

TypeDefault
stringInteract

This property determines the action text shown to the user.

History 4

AutoLocalize

TypeDefault
booltrue

This property determines whether the prompt's ProximityPrompt.ActionText and ProximityPrompt.ObjectText will be localized according to the ProximityPrompt.RootLocalizationTable. When set to true, localization will be applied.

History 4

ClickablePrompt

TypeDefault
booltrue

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.

History 4

Enabled

TypeDefault
booltrue

This property indicates whether or this ProximityPrompt should be shown.

History 4

Exclusivity

TypeDefault
ProximityPromptExclusivityOnePerButton

This property is used to customize which prompts can be shown at the same time.

History 4

GamepadKeyCode

TypeDefault
KeyCodeButtonX

This property determines the gamepad button the player should press to trigger the ProximityPrompt. Default is ButtonX.

History 4

HoldDuration

TypeDefault
float0

This property indicates the duration, in seconds, that the player must hold the button/key down to trigger the prompt.

History 4

InputHoldBegin

Parameters (0)
No parameters.
Returns (1)
null

This function triggers a signal indicating that the user began pressing the ProximityPrompt prompt button. It should be used by developers who wish to customize the prompt and trigger it from a prompt GUI button press.

History 3

InputHoldEnd

Parameters (0)
No parameters.
Returns (1)
null

A counterpoint to ProximityPrompt:InputHoldBegin(), this signals that the user ended pressing the prompt GUI button.

History 3

KeyboardKeyCode

TypeDefault
KeyCodeE

This property determines the key the player should press to trigger the ProximityPrompt. Default is E.

History 4

MaxActivationDistance

TypeDefault
float10

This property determines the maximum distance a Player's character can be from the ProximityPrompt for the prompt to appear.

History 4

ObjectText

TypeDefault
string

This optional property determines the optional object name text shown to the user.

History 3

PromptButtonHoldBegan

Parameters (1)
playerWhoTriggeredPlayer

This event triggers when a player begins holding down the key/button on a prompt with a non-zero ProximityPrompt.HoldDuration. One possible usage includes to animate a hold progress bar.

History 4

PromptButtonHoldEnded

Parameters (1)
playerWhoTriggeredPlayer

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.

History 4

PromptHidden

Parameters (0)
No parameters.

This event triggers when the prompt becomes hidden. This event is triggered client-side for LocalScripts.

History 2

PromptShown

Parameters (1)
inputTypeProximityPromptInputType

This event triggers when the prompt becomes visible. This event is triggered client-side for LocalScripts.

History 2

RequiresLineOfSight

TypeDefault
booltrue

This property indicates whether the prompt is hidden if the path between the player's Camera and object parented to the ProximityPrompt is obstructed. If true, this prompt will only be shown if there is a clear path from the camera to the object.

The parent Part or Model of the prompt will be excluded from this check.

History 4

RootLocalizationTable

TypeDefault
LocalizationTable

This property serves as a reference to the LocalizationTable used to apply automated localization to the prompt's ProximityPrompt.ActionText and ProximityPrompt.ObjectText. In order for this to apply, ProximityPrompt.AutoLocalize must be set.

Developers can set this to reference a LocalizationTable anywhere in the DataModel. It is not required to be a child of LocalizationService. 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.

History 4

Style

TypeDefault
ProximityPromptStyleDefault

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.PromptShown and ProximityPrompt.PromptHidden events in a LocalScript, where developers should create and tear down the UI.

Developers may also use ProximityPrompt.PromptButtonHoldBegan and ProximityPrompt.PromptButtonHoldEnded in order to utilize the ProximityPrompt.HoldDuration progress animation feature.

History 4

TriggerEnded

Parameters (1)
playerWhoTriggeredPlayer

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.)

History 3

Triggered

Parameters (1)
playerWhoTriggeredPlayer

This event is triggered when the prompt key/button is pressed, or after a specified amount of time holding the button, if ProximityPrompt.HoldDuration is used.

History 3

UIOffset

TypeDefault
Vector20, 0

This property indicates the pixel offset applied to the prompt's UI.

History 4

Settings