Sound not playing when tool is activated

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want my script to play the petition sound every time I click it and a cooldown of 7 seconds

  2. What is the issue? I’ve tried switching around the wait(7) to the different parts of the script but still doesn’t work, also I don’t know how to script so that’s another problem

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Tool = script.Parent

Tool.Activated:Connect(function()
	Tool.Handle.PetitionNow:Play()
	wait(7)
end)

Please help!

When an event is fired, it will automatically create a new thread, which means it will create a new script to run the code.

So instead, you need to use a debounce.

You need a debounce:

local debounce = false

if not debounce then
debounce = true
—play sound
wait(7)
debounce = false
end

Where would I add that in the script?

local Tool = script.Parent
local debounce = false 

Tool.Activated:Connect(function()
if not debounce then
debounce = true
tool.handle.petitionnow:Play()
wait(7)
debounce = false
end
end)
2 Likes

Thank you so much!! This is what I’ve been looking for!