# ProximityPromptService

ProximityPromptService : `Instance`

## Overview

A service that globally manages all ProximityPrompts in the world.

It can be obtained via `game:GetService("ProximityPromptService")`.&#x20;

By listening to events through this service instead of individual ProximityPrompt instances, you can handle all prompt interactions in the world from a single location.

## Properties

### MaxPromptsVisible

`number`

The maximum number of prompts that can be displayed on screen simultaneously.

#### Code Samples

```lua
local ProximityPromptService = game:GetService("ProximityPromptService")
ProximityPromptService.MaxPromptsVisible = 3
```

### Enabled

`boolean`

Enables or disables the ProximityPrompt feature for the entire service.&#x20;

Setting this to false hides all prompts in the world.

#### Code Samples

```lua
local ProximityPromptService = game:GetService("ProximityPromptService")
ProximityPromptService.Enabled = false
```

## Methods

## Events

### PromptShown

This event fires when any ProximityPrompt in the world becomes visible.

This event only functions in the client environment.

#### Parameters

| `ProximityPrompt` prompt | The ProximityPrompt instance that was shown. |
| ------------------------ | -------------------------------------------- |

#### Code Samples

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

ProximityPromptService.PromptShown:Connect(function(prompt)
    print(prompt.ObjectText .. " prompt is now visible.")
end)
```

### PromptHidden

This event fires when any ProximityPrompt in the world is hidden.

This event only functions in the client environment.

#### Parameters

| `ProximityPrompt` prompt | The ProximityPrompt instance that was hidden. |
| ------------------------ | --------------------------------------------- |

#### Code Samples

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

ProximityPromptService.PromptHidden:Connect(function(prompt)
    print(prompt.ObjectText .. " prompt is now hidden.")
end)
```

### PromptTriggered

This event fires when any ProximityPrompt in the world is activated.

#### Parameters

| `ProximityPrompt` prompt | The ProximityPrompt instance that was activated. |
| ------------------------ | ------------------------------------------------ |
| `Player` player          | The player who activated the prompt.             |

#### Code Samples

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

ProximityPromptService.PromptTriggered:Connect(function(prompt, player)
    print(player.Name .. " interacted with " .. prompt.ObjectText)
end)
```

### PromptTriggerEnded

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

#### Parameters

| `ProximityPrompt` prompt | The ProximityPrompt instance. |
| ------------------------ | ----------------------------- |
| `Player` player          | The related player.           |

#### Code Samples

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

ProximityPromptService.PromptTriggerEnded:Connect(function(prompt, player)
    print(player.Name .. "'s trigger has ended.")
end)
```

### PromptButtonHoldBegan

This event fires when a player begins holding the button for any ProximityPrompt in the world.

#### Parameters

| `ProximityPrompt` prompt | The ProximityPrompt instance.              |
| ------------------------ | ------------------------------------------ |
| `Player` player          | The player who started holding the button. |

#### Code Samples

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

ProximityPromptService.PromptButtonHoldBegan:Connect(function(prompt, player)
    print(player.Name .. " started holding.")
end)
```

### PromptButtonHoldEnded

This event fires when a player releases the button for any ProximityPrompt in the world.

#### Parameters

| `ProximityPrompt` prompt | The ProximityPrompt instance.       |
| ------------------------ | ----------------------------------- |
| `Player` player          | The player who released the button. |

#### Code Samples

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

ProximityPromptService.PromptButtonHoldEnded:Connect(function(prompt, player)
    print(player.Name .. " stopped holding.")
end)
```

## See also

{% content-ref url="../../../manual/studio-manual/object/proximityprompt" %}
[proximityprompt](https://docs.overdare.com/manual/studio-manual/object/proximityprompt)
{% endcontent-ref %}
