Hi, I have a script right now that randomises the music on my game but the problem is I've tried but I just cant figure out how to add a mute button to it.
I don't mind changing the music system as long as it still picks a random song and can mute.
Script for random song:
wait(1)
while true do
local Sounds = script:GetChildren()
local RandomIndex = math.random(1,#Sounds)
local RandomSound = Sounds[RandomIndex]
RandomSound:Play()
wait(RandomSound.TimeLength)
end
Script for mute gui:
local Music = workspace.Music:GetChildren() --grabs audio from underneath music script
script.Parent.Value.Value = 0 -- sets mute gui value to 0
function onClicked() -- when mute button is pressed
if script.Parent.Value.Value == 0 then
for i,v in pairs(Music) do --for all the stuff below music script:
if v:IsA("Sound") then -- if thing below music script is a Sound then
v.Volume = 0 --set the volume to 0
script.Parent.BackgroundColor3 = Color3.fromRGB(202, 0, 0) --change mute gui colour to red
script.Parent.Value.Value = 1 --sets mute gui value to 1
else
v.Volume = 0.3 -- turns volume on
script.Parent.BackgroundColor3 = Color3.fromRGB(29, 119, 214) --sets mute gui colour to normal
script.Parent.Value.Value = 0 --sets mute gui value to 0
end
end
end
end

2 comments
Maybe create for I, v loop then create a variable and call the randomizer function. If a player wants to mute it create a image button GUI, attach a local script and make it so when it's clicked all of the sounds become disabled if that makes sense
ty for replying, ive edited the question above to show what ive tried to do. the mute isnt working still but ive tried to annotate the script to my best ability. I only know how to code python so im kinda half guessing whenever i script - hope you can help, thanks :)