> For the complete documentation index, see [llms.txt](https://docs.overdare.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overdare.com/development/api-reference/classes/proximityprompt.md).

# 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

```lua
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

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

Prompt.AutoLocalize = false
```

### 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

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

Prompt.ClickablePrompt = true
```

### Enabled

`boolean`

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

#### Code Samples

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

Prompt.Enabled = false
```

### 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

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

Prompt.Exclusivity = Enum.ProximityPromptExclusivity.OnePerButton
```

### 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

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

Prompt.HoldDuration = 1.5
```

### 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

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

Prompt.KeyboardKeyCode = Enum.KeyCode.E
```

### 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

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

Prompt.MaxActivationDistance = 5
```

### ObjectText

`string`

The object name text displayed in the prompt UI.

#### Code Samples

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

Prompt.ObjectText = "Treasure chest"
```

### 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

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

Prompt.RequiresLineOfSight = true
```

### UIOffset

`Vector2`

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

#### Code Samples

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

Prompt.UIOffset = Vector2.new(0, 50)
```

## Methods

### InputHoldBegin

Called when a hold input begins.

#### Parameters

#### Return

| `void` |   |
| ------ | - |

#### Code Samples

```lua
local prompt = workspace.InteractPart.ProximityPrompt
prompt:InputHoldBegin()
```

### InputHoldEnd

Called when a hold input ends.

#### Parameters

#### Return

| `void` |   |
| ------ | - |

#### Code Samples

```lua
local prompt = workspace.InteractPart.ProximityPrompt
prompt:InputHoldEnd()
```

## 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

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

Prompt.PromptButtonHoldBegan:Connect(function(player)
    print("Hold began.", player.Name)
end)
```

### PromptButtonHoldEnded

This event fires when a player releases the prompt button.

#### Parameters

| `Player` player | The player who released the button. |
| --------------- | ----------------------------------- |

#### Code Samples

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

Prompt.PromptButtonHoldEnded:Connect(function(player)
    print("Hold ended.", player.Name)
end)
```

### PromptHidden

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

This event only functions in the client environment.

#### Parameters

#### Code Samples

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

Prompt.PromptHidden:Connect(function()
    print("Prompt is now hidden.")
end)
```

### 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

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

Prompt.PromptShown:Connect(function(inputType)
    print("Prompt is now visible.", inputType)
end)
```

### 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

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

Prompt.Triggered:Connect(function(player)
    print("Prompt triggered!", player.Name)
end)
```

### 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

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

Prompt.TriggerEnded:Connect(function(player)
    print("Trigger ended.", player.Name)
end)
```

## See also

{% content-ref url="/pages/pJZBTtT2zwhjOt2pGLTm" %}
[ProximityPrompt](/manual/studio-manual/object/proximityprompt.md)
{% endcontent-ref %}
