Clone all sounds into one soundgroup

So i’ve been trying to mess around soundservice for a while especially with setting the volumes of some audios, however i came to a realization that it’s not possible to change ALL of the audio in-game volume in one setting, so i wanted to try soundservice to see if it works, however i would have to clone all of the sounds to the group.

local __SOUNDSERVICE = game:GetService("SoundService")
for _,__SFX in pairs(game:GetDescendants()) do
	if __SFX:IsA("Sound") then
		local __CLONES = __SFX:Clone()
		__CLONES.Parent = __SOUNDSERVICE:WaitForChild("Main")
	end
end

is there a better approach to this? Because i’m afraid it’ll cause some hefty lag.

If you’re frequently changing properties of every sound in the game, consider adding them to a table to iterate later. Such as:

local sounds = {}

for  _, v in game:GetDescendants() do -- Note this should be workspace, playerscripts, etc. Game is going to take very long to iterate through things Sounds can't even play from.
   if not v:IsA("Sound") then continue end
   table.insert(sounds, v)
end

[...]

for _, v in sounds do
    v.Volume = 0.5
end

You could, in your provided code, just reparent the existing Sound to the soundgroup, instead of cloning it. But that may mess up instance hierarchies other scripts rely upon.
Based on your application it may be better to instead assign sounds’ volumes to a global variable only when the sound is being played, so time isn’t spent iterating through a majority of sounds that aren’t playing.

My natural approach was to change every sound playing in workspace to volume 0.5 during a function then revert those sounds to their default volume (what they were originally) after the function ends but ill try your solution.

Please look into Sound.SoundGroup and SoundGroups themselves.

Iterating through every object in workspace just to change every sound’s volume is unnecessary when you could just assign Sound.SoundGroup to a specific SoundGroup and just change the volume on the SoundGroup instead, since SoundGroup.Volume acts as a multiplier to the sounds in it.