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!

6 comments
It doesnt even play the sound at all, when i touch the brick
Are there any errors?
Nothing, I just did something wrong, is there anyway this could be made compatiable with the PlayerGui thing so that only the Tycoon owner heres it?
Like in the last question you helped me on?
Yeah.. do pretty much exactly what I helped you with in the last question
Thanks for helping me on this stuff, your the only one who ever helps meh. :D