You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am here because I would like to know how it is possible to prevent people from spamming a sound a button that opens a door makes. -
What is the issue? Include screenshots / videos if possible!
I’m having trouble finding out how I can add a cooldown to a specific part of my TweenService script (which opens a heavy blast door.) When the button that opens the door is pressed, the door will open and a sound will play. I dont run into any problems until I realize that the door’s open sound will play if you try to click it again mid-animation or during its open/close cooldown.
Here is the part of the script I am trying to change.
script.Parent.MouseClick:connect(function()
if open == false then
Open1:Play()
Open2:Play()
script.Parent.Sound:Play()
wait(15)
open = true
else
Close1:Play()
Close2:Play()
script.Parent.Sound:Play()
wait(15)
open = false
end
end)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
So far, I have tried moving the “wait(15)” command to different parts of the script, to see if it would cool down the sound as well as the door open/close tween animations. I have heard of debouncing, but I don’t know how to insert a debounce in between this part of the script without ending up ruining something else.
What should I do?