Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to detect if player is holding down proximity prompt?

Asked by 2 years ago

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

2 answers

Log in to vote
1
Answered by
Soban06 410 Moderation Voter
2 years 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.

Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years 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 — 2y

Answer this question