# ProximityPrompt（ロブロックス クラス）

> パーツに近づくと「Eキーで調べる」のような表示が出て、ボタンを押すと処理を実行できる部品です。

- URL：https://roblox.minecraft-okinawa.com/reference/classes/ProximityPrompt/
- 公式：https://create.roblox.com/docs/reference/engine/classes/ProximityPrompt
- 受け継いでいるクラス：Instance

## 使用例：近づいて宝箱をひらく

（Script／置く場所：宝箱にするパーツの中）

```lua
local part = script.Parent :: BasePart
local prompt = Instance.new("ProximityPrompt")
prompt.ActionText = "ひらく"
prompt.ObjectText = "宝箱"
prompt.Parent = part

prompt.Triggered:Connect(function(player)
	print(player.Name .. " が宝箱をひらいた！")
	part.BrickColor = BrickColor.new("Bright yellow")
end)
```

## プロパティ

- `ProximityPrompt.ActionText: string`：ボタンに表示する行動の文字（例：ひらく）。
- `ProximityPrompt.AutoLocalize: boolean`：Whether the prompt's ProximityPrompt.ActionText and ProximityPrompt.ObjectText will be localized according to the ProximityPrompt.RootLocalizationTable.
- `ProximityPrompt.ClickablePrompt: boolean`：Whether the prompt can be activated by clicking/tapping on the prompt UI.
- `ProximityPrompt.Enabled: boolean`：Whether or not this prompt should be shown.
- `ProximityPrompt.Exclusivity: ProximityPromptExclusivity`：Used to customize which prompts can be shown at the same time.
- `ProximityPrompt.GamepadKeyCode: KeyCode`：The gamepad button the player should press to trigger the prompt.
- `ProximityPrompt.HoldDuration: float`：ボタンを長押しする必要がある秒数。
- `ProximityPrompt.KeyboardKeyCode: KeyCode`：使うキー。初期値はEキーです。
- `ProximityPrompt.MaxActivationDistance: float`：表示される最大の距離。
- `ProximityPrompt.MaxIndicatorDistance: float`：The maximum distance at which a lightweight indicator for the prompt is shown, hinting at a nearby interaction before the player is close enough to trigger it.
- `ProximityPrompt.ObjectText: string`：対象の名前の文字（例：宝箱）。
- `ProximityPrompt.RequiresLineOfSight: boolean`：Whether the prompt is hidden if the path between the player's Camera and object parented to the ProximityPrompt is obstructed.
- `ProximityPrompt.RootLocalizationTable: LocalizationTable`：A reference to a LocalizationTable to be used to apply automated localization to this prompt's ProximityPrompt.ActionText and ProximityPrompt.ObjectText.
- `ProximityPrompt.Style: ProximityPromptStyle`：The style of the prompt's UI.
- `ProximityPrompt.UIOffset: Vector2`：The pixel offset applied to the prompt's UI.

## メソッド

- `ProximityPrompt:InputHoldBegin(): ()`：Fires a signal indicating that the user began pressing the prompt GUI button.
- `ProximityPrompt:InputHoldEnd(): ()`：Fires a signal indicating that the user ended pressing the prompt GUI button.

## イベント

- `ProximityPrompt.IndicatorHidden()`：Fires on the client when a lightweight indicator for the prompt is no longer shown.
- `ProximityPrompt.IndicatorShown()`：Fires on the client when a lightweight indicator for the prompt becomes visible.
- `ProximityPrompt.PromptButtonHoldBegan(playerWhoTriggered: Player)`：Triggered when a player begins holding down the Class.ProximityPrompt.KeyboardKeyCode|key/button connected to a prompt with a non-zero ProximityPrompt.HoldDuration.
- `ProximityPrompt.PromptButtonHoldEnded(playerWhoTriggered: Player)`：Triggers when the player ends holding down the button on a prompt with a non-zero ProximityPrompt.HoldDuration.
- `ProximityPrompt.PromptHidden()`：Triggers when the Class.ProximityPrompt|prompt becomes hidden.
- `ProximityPrompt.PromptShown(inputType: ProximityPromptInputType)`：Triggers when the Class.ProximityPrompt|prompt becomes visible.
- `ProximityPrompt.Triggered(playerWhoTriggered: Player)`：プレイヤーがボタンを押したときに発生するイベントです。
- `ProximityPrompt.TriggerEnded(playerWhoTriggered: Player)`：Triggers when Class.ProximityPrompt.KeyboardKeyCode|key/button is released, for longer events where the user is required to hold down the button.

英語の説明とメンバー一覧：Roblox Creator Documentation（CC BY 4.0）。日本語の解説はこのサイト独自のものです。

執筆：鈴木孝昌（現役プロジェクトマネージャー／プログラミング講師）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）