Hello y'all,
I'll start off by showing what my code is at the moment:
Shrek = game.Workspace.Shrek.Head Allstarsound = game.Workspace.Allstar ShrekTouched = Shrek.Touched function Allstar() Allstarsound:Play() wait (59) Allstarsound:Stop() end Shrek.Touched:connect(Allstar)
I want the "Shrek.Touched:connect(Allstar)" part to have a cooldown, so the sound wont start again when you start it. I tried the following code:
if Shrek.Touched then Allstar() wait (75) end
Which ended me up with the sound to be played when joined.
If you have any questions, feel free to ask me.
You can use a cooldown debounce.
Shrek = game.Workspace.Shrek.Head Allstarsound = game.Workspace.Allstar local isInCooldown = false local cooldownTime = 75 function Allstar() if isInCooldown then return end Allstarsound:Play() wait (59) Allstarsound:Stop() isInCooldown = true wait(cooldownTime) isInCooldown = false end Shrek.Touched:connect(Allstar)