Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get sound to play in sync with the animations?

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)

1 answer

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.

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.