How would you get all of the sounds?

image

I have speakers placed around my building (as shown in the image), I would like players to be able to change the audio inside, The problem is I don’t know how to get all the Sounds from the parts at the same time. Any Ideas?

I haven’t tried anything because I simply just don’t know!

A simple way to get all the sounds would be this

local speakers = workspace.Speakers -- or where the folder is

local audios = {}

for _,v in pairs(speakers:GetDescendants()) do
	if v:isA("Sound") then
		table.insert(audios,v)
	end
end

Thanks, I’m useless with this stuff! How would I layout the audios inside the audios?

Wait what do you mean by that?

local audios = {}

Would I add the Id’s inside with commas in-between?

You don’t have to do that, table.insert() would handle this.

1 Like

Alright, thanks for your help!

1 Like

Yup, as @ItzMeZeus_IGotHacked mentioned, they get added by themselves when a sound is found in the folder via table.insert, if you have anymore issues don’t be afraid to make another post!

1 Like

How would i get every audio and play them?

for i,v in pairs(Speakers)
if v.Name == "Sound"
v.Play()