Hello, TixyScripter here with another question dealing with Sound.... I currently have this script that has a Debounce so that people cannot spam the sound when they touch the brick.
debounce = false --use a debounce to check if it's playing already or not function onTouched(hit) script.Parent.Touched:connect(function(hit) --touched event if debounce == false then --after it's touched, if debounce is false then debounce = true --changes debounce to true script.Parent.Sound:Play() --plays sound/song wait(1) --waits 60 seconds (the length of a song) debounce = false --resets debounce to false, so it's playable after 60 seconds script.Parent.Sound:Stop() --stops the song else --otherwise song is already playing print('already playing') --prints that it's already playing end end) script.Parent.Touched:connect(onTouched)
When I touch the brick the sound doesn't play at all and I don't know why, please halp!
Why do you have two functions inside of eachother? Just remove the first one and you should be good.
debounce = false script.Parent.Touched:connect(function(hit) if debounce == false then debounce = true script.Parent.Sound:Play() wait(1) debounce = false script.Parent.Sound:Stop() else print('already playing') end end)