For this you gotta use tables! A table (or you can call it an array) is pretty much a variable that can store multiple values, and such as variables tables can have different types of values (integer, string, boolean, number.....).
For more information
A table is assigned like this t = {1, true, "runs"} its like that, it stores different values, and to get those values you gotta do for example t[the index of the value] so for example t[3] is "runs" in the table we assigned earlier, now after storing these audio objects in our table, it will be boring to mention them one by one, so we gotta loop tem, and loop te memebers of a table we gotta use an in pairs loop. I probarly not gonna be good at explaining this so here
you go
local b = game.Workspace.musicbrick
local audios = {b.audio1,
b.audio2,
b.audio3,
b.audio4,
b.audio5,
b.audio6,
b.audio7}
for i, v in pairs(audios) do
v:Stop()
end
Now we can make this way efficent by doing
for i,v in pairs(game.Workspace.musicbrick:GetChildren()) do
if v:IsA("Sound") then
v:Stop()
end
end
And that's it! sorryf or the poor explanation, i got a perfect explantion here
1 comment
thank you! this is perfect :)