The sword plays a random animation every time you click, this works fine, but I'm trying to get sound to sync with the animations, because when I spam click the mouse, you can barely hear the sound cause its being played so many times.
I tried adding a cool down, but that doesnt help. I was thinking on a debounce but I'm not sure how I would go about this.
here is the code:
Sword.Activated:Connect(function() Sword.Handle.Slash:Play() end)
local debounce = false Sword.Activated:Connect(function() if debounce then return end -- so it doesn't run if cooldown debounce = true -- set cooldown to true Sword.Handle.Slash:Play() wait(cooldown) debounce = false -- set cooldown to false end)
debounce and cooldown are the same thing. Also there is a sound property called "IsPlaying" so you can check if the sound is already playing.