0

# How to detect if player is holding down proximity prompt?

I've tried to use promptbuttonholdbegan but it didnt work can someone help

1
Soban06 390
3 months ago

Alright this is quite simple. You will need 2 Events for Proximity Prompts (Triggered and PromptButtonHoldEnded).

Here is how you will implement it within your script (script inside the proximity prompt):

local IsHoldingDownPrompt = false

script.Parent.Triggered:Connect(function()
IsHoldingDownPrompt = true
end)

script.Parent.PromptButtonHoldEnded:Connect(function()
IsHoldingDownPrompt = false
end)

while IsHoldingDownPrompt do
-- Here you can do whatever you want if the prompt is being held. And if the prompt get's released, then this code won't run.
end



Hope it helps.

0
Edited 3 months ago

You will need to trigger the proximity prompt.

local ProximityPrompt =  --Put where the proximity prompt is located e.g script.Parent
ProximityPrompt.Triggered:Connect(function()


Then if you want something to happen after the player holds down the proximity prompt, put your script after it. E.G

local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function()
if ProximityPrompt.ActionText = "Hi" then --this part indicates if the text on the Proximity prompt says 'Hi' then the script after will activate after the proximity prompt is activated by the player.
game.Workspace.Part.Transparency = 0.5 -- this means if the ProximityPrompt is triggered, the Transparency will change to 0.5 Transparency.


Hope this helped.

0
i want it to detect if keep holding it mishokirva 22 — 3mo