I recently asked a question how you can mute all sound and I got the answer from RoCopSSS but i'm not sure how I can put them both into a single button
mute
local store = {} for i, object in pairs(workspace:GetDescendants()) do if object.ClassName == "Sound" then table.insert(store, #store + 1, {['Object'] = object, ['Vol'] = object.Volume}) object.Volume = 0 end end end
unmute
for i, v in pairs(store) do -- reads store table if v.Object then -- checks if the object still exists v.Object.Volume = v.Vol -- sets the object value to the saved volume value end end
everything I've tried has errored any help?
I recommend using this
local store = {} -- declare it here so both functions can access it MuteButton.MouseButton1Down:Connect(function() for i, object in pairs(workspace:GetDescendants()) do if not table.find(store, object) then -- prevents from adding one part 2 times if object.ClassName == "Sound" then table.insert(store, #store + 1, {['Object'] = object, ['Vol'] = object.Volume}) object.Volume = 0 end end end end end) UnmuteButton.MouseButton1Down:Connect(function() for i, v in pairs(store) do -- reads store table if v.Object then -- checks if the object still exists v.Object.Volume = v.Vol -- sets the object value to the saved volume value end end store = {} -- clear the table end)