Can somebody help me add in a wait? When I touch the brick, the sound play and it work but I don't want someone to just keep touching the brick over and over without waiting for a second or so to make the sound play again. It also lag too and I don't know why...
script.Parent.Touched:connect(function() script.Parent.Sound:Play() end)
This is simple. We're just going to make a bool variable
, and if the variable is true, then we play the sound and make the variable false, wait a while, and make it true again.
Example,
local Debounce = true script.Parent.Touched:connect(function() if Debounce then Debounce = false script.Parent.Sound:Play() wait(5)-- Wait As long as you want Deounce = true end end)
Good Luck!