Erikmb
(HecknIrishMan)
#1
Is there a way that I could use :Connect to do a function on multiple audios such as in the demonstration below?
sound01.Played or sound02.Played:Connect(function()
print("a sound has played")
end)
Obviously the code above doesn’t work. But is there a way that it could? Or would I have to copy and paste :Connect(function() for each audio.
ayoub50
(Ayoub)
#2
function Check()
print("a sound has played")
end
sound01.Played:Connect(Check)
sound02.Played:Connect(Check)
2 Likes
Ripxff
(bhdb)
#3
Better than what I was typing at the moment LMAO this is the best way to approach this 
1 Like
Erikmb
(HecknIrishMan)
#4
Wow never would have thought of that! Need to remember that you can add functions inside brackets. Thank you!!
1 Like
Valkyrop
(JustAGuy)
#5
local sounds = {sound1,sound2,sound3}
local function Test()
print("Works!")
end
for _,Sound in pairs(sounds) do
Sound.Played:Connect(Test)
end
1 Like
ayoub50
(Ayoub)
#6
both works, i don’t think he would need alot of sounds to connect in the same function.
Erikmb
(HecknIrishMan)
#7
Well, I have 9 sounds so this is deff cleaner in the script. And gets rid of the distracting block I had lol
