Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Changing multiple children in one line?

None of this is red

Outputs not saying anything is wrong

Its just not working

workspace.Music.Music:GetChildren().Volume = 0

Music is a folder and I'm trying to change all of the audios inside of it to the volume 0 But its just not working

Any ideas as to why its not working?

1 answer

✓ Accepted answer

:GetChildren() is a function used to get the children of an instance and returns it as an array. Since this gives you an array, you could use a generic for-loop to iterate through every child/value in the array.

local MusicFolder = workspace.Music --Gets the folder of music

for _, song in ipairs(MusicFolder:GetChildren()) do
	if song:IsA("Sound") then
		song.Volume = 0
	end
end

In the above code, we define our Music folder then get it's children in the loop. The 'song' variable will be the child or value in the array. We then set it's Volume if it's a Sound object.

If I missed anything or you need anything explained let me know.

###GetChildren()

This discussion is preserved as it was. New answers, comments, and votes are closed.