How can i detect if player stopped holding the prompt, without triggering the proximity prompt?
the prompt hold duration is 9 seconds
the script:
local ProximityPrompt = script.Parent
local StartingSound = script.Parent.Parent.Parent.Part.Starting
ProximityPrompt.PromptButtonHoldBegan:Connect(function()
StartingSound:Play()
print("Player is starting the machine")
end)
ProximityPrompt.PromptButtonHoldEnded:Connect(function()
if ProximityPrompt.Triggered then
StartingSound:Resume()
print("Player successfully started the machine")
else
StartingSound:Stop()
print("Player failed to start the machine")
end
end)
ProximityPrompt.Triggered is an event, so I don’t think it quites work in the if statement.
May be a better solution to what I have provided below, but it should still work:
local ProximityPrompt = script.Parent
local StartingSound = script.Parent.Parent.Parent.Part.Starting
ProximityPrompt.PromptButtonHoldBegan:Connect(function()
StartingSound:Play()
local Triggered = false
print("Player is starting the machine")
local conn1 = ProximityPrompt.PromptButtonHoldEnded:Once(function()
task.wait()
if Triggered then
StartingSound:Resume()
print("Player successfully started the machine")
else
StartingSound:Stop()
print("Player failed to start the machine")
conn2:Disconnect()
end
end)
local conn2 = ProximityPrompt.Triggered:Once(function()
Triggered = true
end)
end)
Forgot to put local in front of them. Conn1 and Conn2 are the variables I assigned the event connections to. The yellow line can be ignored or can be silenced by putting local in front of them. i.e.