For the complete documentation index, see llms.txt. This page is also available as Markdown.

ProximityPrompt

ProximityPrompt : Instance

Overview

ProximityPrompt is a class that displays interactive actions and input prompts on the screen when a player approaches an object.

This feature is used as a UI element that intuitively informs players which objects can be interacted with. It can be applied to various objects such as chests, doors, resources, NPCs, and devices, and is widely used in exploration, RPG, and survival genre games.

ProximityPrompt supports two types of interaction methods: Press input and Hold input.

Properties

ActionText

string

The action instruction text displayed in the prompt UI.

Code Samples

local Workspace = game:GetService("Workspace")
local Prompt = Workspace.Part.ProximityPrompt

Prompt.ActionText = "Open"

AutoLocalize

boolean

Determines whether automatic localization (Auto Translation) is applied to this ProximityPrompt's ActionText and ObjectText. If AutoLocalize is true, the text is also included in Automatic Text Collection (ATC).

The default value is true. If set to false, the prompt text is not translated.

Code Samples

ClickablePrompt

boolean

Specifies whether the prompt can be activated by a mouse click.

It does not function in mobile environments, so it is recommended to use it only for testing convenience in the Studio play test environment.

Code Samples

Enabled

boolean

Specifies whether the prompt is enabled. Setting this to false hides the prompt.

Code Samples

Exclusivity

Enum.ProximityPromptExclusivity

Specifies how many prompts can be shown simultaneously when multiple prompts share the same button.

  • OnePerButton: Only one prompt is shown per key.

  • OneGlobally: Only one prompt is shown globally.

  • AlwaysShow: Always shown regardless of other prompts.

Code Samples

HoldDuration

number

The duration in seconds that the button must be held to activate the prompt. Setting this to 0 activates the prompt immediately upon pressing.

Code Samples

KeyboardKeyCode

Enum.KeyCode

Specifies the keyboard key used to activate the prompt.

It is not displayed on mobile environments, so it is recommended to use it only for testing convenience in the Studio play test environment.

Code Samples

MaxActivationDistance

number

The maximum distance at which a player's character can activate the prompt.

When multiple ProximityPrompts overlap, UI display and interaction handling are based on the Prompt that is detected first rather than the one closest to the player. As a result, an unintended Prompt may be selected. To avoid unexpected behavior, it is recommended not to place ProximityPrompts in overlapping positions.

Code Samples

ObjectText

string

The object name text displayed in the prompt UI.

Code Samples

RequiresLineOfSight

boolean

Specifies whether a clear line of sight to the object is required to activate the prompt.

When true, prompts on objects blocked by obstacles will not be activated.

Code Samples

UIOffset

Vector2

Specifies the screen offset (in pixels) of the prompt UI.

Code Samples

Methods

InputHoldBegin

Called when a hold input begins.

Parameters

Return

void

Code Samples

InputHoldEnd

Called when a hold input ends.

Parameters

Return

void

Code Samples

Events

PromptButtonHoldBegan

This event fires when a player begins holding the prompt button.

Parameters

Player player

The player who started holding the button.

Code Samples

PromptButtonHoldEnded

This event fires when a player releases the prompt button.

Parameters

Player player

The player who released the button.

Code Samples

PromptHidden

This event fires when the prompt UI is hidden from the screen.

This event only functions in the client environment.

Parameters

Code Samples

PromptShown

This event fires when the prompt UI becomes visible on screen.

This event only functions in the client environment.

Parameters

Enum.ProximityPromptInputType inputType

The input type that caused the prompt to be shown.

Code Samples

Triggered

This event fires when a player successfully activates the prompt.

Use this event to handle the logic that should run when the prompt is actually executed.

Parameters

Player player

The player who activated the prompt.

Code Samples

TriggerEnded

This event fires when an in-progress prompt trigger completes or is cancelled.

Parameters

Player player

The player who was performing the trigger.

Code Samples

See also

ProximityPrompt

Last updated