---
title: "Proximity prompts"
url: /docs/en-us/tutorials/use-case-tutorials/ui/proximity-prompts
last_updated: 2026-06-11T23:12:05Z
description: "The process for creating an interactive prompt that triggers an action on user input."
---

# Proximity prompts

You can create interactive proximity prompts that appear when users approach objects in the 3D space, then trigger actions on user input.

This tutorial uses the [Dungeon Delve](https://www.roblox.com/games/6749940622/Dungeon-Delve-Learn) project as a showcase. To follow along, open it in Studio before proceeding.

![Edit in Studio option from the experience's main page](../../../assets/tutorials/proximity-prompts/Dungeon-Delve-Edit-Place.png) ## Create a prompt

On-screen prompts are generated by a `Class.ProximityPrompt` object parented to an `Class.Attachment`, `Class.BasePart`, or `Class.Model`.

1. Select the **PrisonDoor** model in the 3D view or from the **Explorer** (**Workspace** → **PromptObjects** → **PrisonDoor**).
2. Expand its tree and select the **Door** object.
3. Placing a prompt on an `Class.Attachment` gives you more control on where the point of interaction occurs, versus placing it directly on the part/model. Insert a new **Attachment** and rename it to **PromptAttachment**.
4. Locate the new attachment's **Position** property and set it to **-2.25**, **-0.5**, -**0.5**. This will move it in front of the door's key hole.
5. Hover over **PromptAttachment** and insert a new **ProximityPrompt** object.

### Prompt appearance

Prompts consist of three primary elements, each of which can be controlled by the following properties:

- **ObjectText** — An optional name for the object being interacted with.
- **ActionText** — An optional action name shown to the user.
- **KeyboardKeyCode** — The keyboard key which will trigger the prompt.
- **GamepadKeyCode** — The gamepad button which will trigger the prompt.

To customize the appearance of the prison door prompt, make the following changes:

1. In the **Properties** window, locate the **ObjectText** property and type in **Door**.
2. For the **ActionText** property, type in **Pick Lock**.

### Activation distance

Prompts appear when the user's **character** moves within the defined **MaxActivationDistance** range of the prompt object's parent.

The default value works well in most cases, but you can push user interaction closer to the lock by changing **MaxActivationDistance** to **4**.

### Hold duration

The **HoldDuration** property value determines how quickly the prompt's action is triggered, in seconds. Since this door must be picked to unlock it, change the **HoldDuration** property to **4**.

## Implement an action

The best way to detect prompt events is through `Class.ProximityPromptService` — this lets you detect events centrally without attaching a script to each prompt object.

A basic framework is as follows:

```lua
local ProximityPromptService = game:GetService("ProximityPromptService")

-- Detect when prompt is triggered
local function onPromptTriggered(promptObject, player)

end

-- Detect when prompt hold begins
local function onPromptHoldBegan(promptObject, player)

end

-- Detect when prompt hold ends
local function onPromptHoldEnded(promptObject, player)

end

-- Connect prompt events to handling functions
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)
ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)
```

| Event | Description |
| --- | --- |
| `Class.ProximityPromptService.PromptTriggered\|PromptTriggered` | Fires when a user interacts with a prompt (**after** the duration for a prompt with non-zero `Class.ProximityPrompt.HoldDuration\|HoldDuration`). |
| `Class.ProximityPromptService.PromptButtonHoldBegan\|PromptButtonHoldBegan` | Fires when a user begins interacting with a prompt of non-zero `Class.ProximityPrompt.HoldDuration\|HoldDuration`. |
| `Class.ProximityPromptService.PromptButtonHoldEnded\|PromptButtonHoldEnded` | Fires when a user stops interacting with a prompt of non-zero `Class.ProximityPrompt.HoldDuration\|HoldDuration` |

In the [Dungeon Delve](https://www.roblox.com/games/6749940622/Dungeon-Delve-Learn) project, these events are managed by the **PromptEvents** script within **ServerScriptService**.

Inside the script, the events above simply call functions within the **ObjectActions** `Class.ModuleScript`, also located in **ServerScriptService**.

```lua
local ProximityPromptService = game:GetService("ProximityPromptService")
local ServerScriptService = game:GetService("ServerScriptService")

local ObjectActions = require(ServerScriptService.ObjectActions)

-- Detect when prompt is triggered
local function onPromptTriggered(promptObject, player)
	ObjectActions.promptTriggeredActions(promptObject, player)
end

-- Detect when prompt hold begins
local function onPromptHoldBegan(promptObject, player)
	ObjectActions.promptHoldBeganActions(promptObject, player)
end

-- Detect when prompt hold ends
local function onPromptHoldEnded(promptObject, player)
	ObjectActions.promptHoldEndedActions(promptObject, player)
end

-- Connect prompt events to handling functions
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)
ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)
```

Proximity prompts are a convenient and customizable solution for in-game object interaction. Check out the `Class.ProximityPrompt` and `Class.ProximityPromptService` reference pages for even more ways to control prompt behavior, and explore other interactive objects in [Dungeon Delve](https://www.roblox.com/games/6749940622/Dungeon-Delve-Learn) for creative inspiration.