Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to detect if player is holding down proximity prompt?

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

2 answers

✓ Accepted answer

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.

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.

1 comment

0

i want it to detect if keep holding it

This discussion is preserved as it was. New answers, comments, and votes are closed.