I am trying to make sounds in the gui be gui_audio and everything else main_audio, but it falsely sets the stuff in startergui and playergui as main_audio, which is wrong.
function setSoundGroup(parent)
for _, child in ipairs(parent:GetDescendants()) do
if child:IsA("Sound") then
if child:IsDescendantOf(game.Players.LocalPlayer.PlayerGui) or child:IsDescendantOf(game.StarterGui) then
warn(child.Name.."is in plrgui")
child.SoundGroup = game.SoundService.GUI_AUDIO
else
child.SoundGroup = game.SoundService.MAIN_AUDIO
end
end
end
end
-- Apply the function to the entire game
setSoundGroup(game)
game.SoundService.MAIN_AUDIO.Volume = 1
game.SoundService.GUI_AUDIO.Volume = 1