Guys how can i do a music gui

No that part looks fine, but you should make sure the intvalue is named song and is set to 1.

Since it isn’t working, I added prints to the script to debug, test it now and send the output

local musicfolder = game.Workspace:WaitForChild("songs") -- place a folder into workspace. Add three UNLOOPED sounds into the folder named "sound1", "sound2", and "sound3". 
-- Set only sound1's isPlaying property to true

local songnumber = musicfolder.song -- insert an intvalue into the folder called "song". Set the value to 1
local button = script.Parent
local songvolume = 0.8 -- replace with the volume you'd like the song to be
local MuteImage, UnMuteImage = "muteimageid", "unmuteimageid"
local songmuted = false
local lastsongnumber = 3 -- REMEMBER, EVERYTIME YOU ADD A NEW SONG, NAME THE SONG sound4, sound5, etc., THEN UPDATE THIS NUMBER TO WHATEVER THE LAST SONG's NUMBER IS!!!

local function PreLoadMuteImages() 
	game:GetService("ContentProvider"):PreloadAsync({ MuteImage, UnMuteImage })
	print("Done Loading")
end
coroutine.wrap(PreLoadMuteImages)()
local function mute()
	print("attempt to mute")
	for i, v in pairs(musicfolder:GetChildren()) do
		if v.Volume ~= 0 then
			songmuted = false
		end
	end
	if songmuted == false then
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				v.Volume = 0
			end
		end
		button.Image = UnMuteImage
		songmuted = true
		print("muted")
	else
		local songtoplay = musicfolder:FindFirstChild("sound"..songnumber.Value)
		if songtoplay == nil then return end
		songtoplay.Volume = songvolume
		button.Image = MuteImage
		songmuted = false
		print("unmuted")
	end
end


local function changeSong()
	if musicfolder:FindFirstChild("sound"..songnumber.Value) and songnumber.Value ~= lastsongnumber then
		musicfolder:FindFirstChild("sound"..songnumber.Value):Play()
		songnumber.Value += 1
		print("next song: song "..songnumber.Value)
	else
		musicfolder:FindFirstChild("sound1"):Play()
		songnumber.Value = 1
		print("reached the end, restarting")
	end
end


button.MouseButton1Down:Connect(mute)


for i, v in musicfolder:GetChildren() do 
	if v:IsA("Sound") then 
		v.Ended:Connect(changeSong)
	end
end

i did everthing but it didn’t work… i think i will i’m going to give up


here is the debug info

change to this:

local musicfolder = game.Workspace:WaitForChild("songs") -- place a folder into workspace. Add three UNLOOPED sounds into the folder named "sound1", "sound2", and "sound3". 
-- Set only sound1's isPlaying property to true

local songnumber = musicfolder.song -- insert an intvalue into the folder called "song". Set the value to 1
local button = script.Parent
local songvolume = 0.8 -- replace with the volume you'd like the song to be
local MuteImage, UnMuteImage = "muteimageid", "unmuteimageid"
local songmuted = false
local lastsongnumber = 3 -- REMEMBER, EVERYTIME YOU ADD A NEW SONG, NAME THE SONG sound4, sound5, etc., THEN UPDATE THIS NUMBER TO WHATEVER THE LAST SONG's NUMBER IS!!!

local function PreLoadMuteImages() 
	game:GetService("ContentProvider"):PreloadAsync({ MuteImage, UnMuteImage })
	print("Done Loading")
end
coroutine.wrap(PreLoadMuteImages)()
local function mute()
	print("attempt to mute")
	for i, v in pairs(musicfolder:GetChildren()) do
		if v:IsA("Sound") then
			if v.Volume ~= 0 then
				songmuted = false
			end
		end
	end
	if songmuted == false then
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				v.Volume = 0
			end
		end
		button.Image = UnMuteImage
		songmuted = true
		print("muted")
	else
		local songtoplay = musicfolder:FindFirstChild("sound"..songnumber.Value)
		if songtoplay == nil then return end
		songtoplay.Volume = songvolume
		button.Image = MuteImage
		songmuted = false
		print("unmuted")
	end
end


local function changeSong()
	if musicfolder:FindFirstChild("sound"..songnumber.Value) and songnumber.Value ~= lastsongnumber then
		musicfolder:FindFirstChild("sound"..songnumber.Value):Play()
		songnumber.Value += 1
		print("next song: song "..songnumber.Value)
	else
		musicfolder:FindFirstChild("sound1"):Play()
		songnumber.Value = 1
		print("reached the end, restarting")
	end
end


button.MouseButton1Down:Connect(mute)


for i, v in musicfolder:GetChildren() do 
	if v:IsA("Sound") then 
		v.Ended:Connect(changeSong)
	end
end

Then post output

Is the song playing? It’s unlooped right? If so, when it ends, does the next one start? Because maybe the mute part may not work but the playlist is the more complex part of the script. If the playlist is not working, then don’t worry, I’ll just implement it into my game then edit until it works in my Studio app. Then I can send you it when it’s working

there is only one sound that plays after when it ends there is nothing that plays and the mute button does not work, if you can try create a game to test until it works that would really help me

Alright, I’ll do that and check with you tomorrow

Fixed it.
So, when the music is unmuted, what do you want the icon to be?

this icone
téléchargement-removebg-preview

I know, but when the music is playing, which icon do you want it to be?

the icone mute when the sound is playing and when the sound is mute i would it to be unmute icone

So @Capitain_Lefty, make sure all audios volume are set to 0.5
I tested it on my app and it worked, let me know if it works for you

local musicfolder = game.Workspace:WaitForChild("songs") -- place a folder into workspace. Add three UNLOOPED sounds into the folder named "sound1", "sound2", and "sound3". 
-- Set only sound1's isPlaying property to true

local songnumber = musicfolder.song -- insert an intvalue into the folder called "song". Set the value to 1
local button = script.Parent
local songvolume = 0.5 -- replace with the volume you'd like the song to be
local MuteImage, UnMuteImage = "rbxassetid://14327123642", "rbxassetid://14327004664"
local songmuted = false
local lastsongnumber = #musicfolder:GetChildren() - 1 -- don't change this

local function PreLoadMuteImages() 
	game:GetService("ContentProvider"):PreloadAsync({ MuteImage, UnMuteImage })
	print("Done Loading")
end
coroutine.wrap(PreLoadMuteImages)()
local function mute()
	print("attempt to toggle mute")
	for i, v in pairs(musicfolder:GetChildren()) do
		if v:IsA("Sound") then
			if v.Volume ~= 0 then
				songmuted = false
			end
		end
	end
	if songmuted == false then
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				v.Volume = 0
			end
		end
		button.Image = MuteImage
		songmuted = true
		print("muted")
	else
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				if v.Volume == 0 then
					v.Volume = songvolume
					songmuted = false
				end
			end
		end
		button.Image = UnMuteImage
		songmuted = true
		print("unmuted")
	end
end


local function changeSong()
	if musicfolder:FindFirstChild("sound"..songnumber.Value) and songnumber.Value ~= lastsongnumber then
		musicfolder:FindFirstChild("sound"..songnumber.Value+1):Play()
		songnumber.Value += 1
		print("next song: song "..songnumber.Value)
	else
		musicfolder:FindFirstChild("sound1"):Play()
		songnumber.Value = 1
		print("reached the end, restarting")
	end
end


button.MouseButton1Down:Connect(mute)


for i, v in musicfolder:GetChildren() do 
	if v:IsA("Sound") then 
		v.Ended:Connect(changeSong)
	end
end
--[[
Hi Cap! I have high respect for your attempt to code in a second language,
given French is your mother-tongue. Hopefully this script works good for you,
it should as long as you keep the following things in mind:

Any time you add a new song to the list, following the given naming convention:
(sound4, sound5, sound6, etc.)

This script will automatically loop through all songs in order, and when it reaches
the end, it will start over from the beginning

That should be it, I hope your English keeps improving

]]

There’s a message for you at the bottom, please read!

Also make sure the GUI has ResetOnSpawn disabled

Thank you so much it’s finally working ! and you really saved me and sorry fi my english is bad !

1 Like

Hey it’s again me, i have a another problem with your script and i don’t know when a player join the game when the first sound finished there are not music there is no music playing

her eis the script btw

local musicfolder = game.Workspace:WaitForChild("songs") -- place a folder into workspace. Add three UNLOOPED sounds into the folder named "sound1", "sound2", and "sound3". 
-- Set only sound1's isPlaying property to true

local songnumber = musicfolder.song -- insert an intvalue into the folder called "song". Set the value to 1
local button = script.Parent
local songvolume = 0.5 -- replace with the volume you'd like the song to be
local MuteImage, UnMuteImage = "rbxassetid://14337097790", "rbxassetid://14337008762"
local songmuted = false
local lastsongnumber = 10 -- REMEMBER, EVERYTIME YOU ADD A NEW SONG, NAME THE SONG sound4, sound5, etc., THEN UPDATE THIS NUMBER TO WHATEVER THE LAST SONG's NUMBER IS!!!

local function PreLoadMuteImages() 
	game:GetService("ContentProvider"):PreloadAsync({ MuteImage, UnMuteImage })
	print("Done Loading")
end
coroutine.wrap(PreLoadMuteImages)()
local function mute()
	print("attempt to toggle mute")
	for i, v in pairs(musicfolder:GetChildren()) do
		if v:IsA("Sound") then
			if v.Volume ~= 0 then
				songmuted = false
			end
		end
	end
	if songmuted == false then
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				v.Volume = 0
			end
		end
		button.Image = MuteImage
		songmuted = true
		print("muted")
	else
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				if v.Volume == 0 then
					v.Volume = songvolume
					songmuted = false
				end
			end
		end
		button.Image = UnMuteImage
		songmuted = true
		print("unmuted")
	end
end


local function changeSong()
	if musicfolder:FindFirstChild("sound"..songnumber.Value) and songnumber.Value ~= lastsongnumber then
		musicfolder:FindFirstChild("sound"..songnumber.Value+1):Play()
		songnumber.Value += 1
		print("next song: song "..songnumber.Value)
	else
		musicfolder:FindFirstChild("sound1"):Play()
		songnumber.Value = 1
		print("reached the end, restarting")
	end
end


button.MouseButton1Down:Connect(mute)


for i, v in musicfolder:GetChildren() do 
	if v:IsA("Sound") then 
		v.Ended:Connect(changeSong)
	end
end
1 Like

Not sure what the problem is, unfortunately I’m busy, but I think this may be a new topic not sure

In any case, I’ve applied this script to my game and it’s running flawlessly, so maybe there is a difference, here’s the script I’m using now with a few tweaks:

local musicfolder = game.Workspace:WaitForChild("songs") -- place a folder into workspace. Add three UNLOOPED sounds into the folder named "sound1", "sound2", and "sound3". 
-- Set only sound1's isPlaying property to true

local songnumber = musicfolder.song -- insert an intvalue into the folder called "song". Set the value to 1
local button = script.Parent
local songvolume = 0.2 -- replace with the volume you'd like the song to be
local MuteImage, UnMuteImage = "rbxassetid://14327123642", "rbxassetid://14327004664"
local songmuted = false
local lastsongnumber = #musicfolder:GetChildren() - 1 -- don't change this

local function PreLoadMuteImages() 
	game:GetService("ContentProvider"):PreloadAsync({ MuteImage, UnMuteImage })
	print("Done Loading")
end
coroutine.wrap(PreLoadMuteImages)()
local function mute()
	print("attempt to toggle mute")
	for i, v in pairs(musicfolder:GetChildren()) do
		if v:IsA("Sound") then
			if v.Volume ~= 0 then
				songmuted = false
			end
		end
	end
	if songmuted == false then
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				v.Volume = 0
			end
		end
		button.Image = MuteImage
		songmuted = true
		print("muted")
	else
		for i, v in pairs(musicfolder:GetChildren()) do
			if v:IsA("Sound") then
				if v.Volume == 0 then
					v.Volume = songvolume
					songmuted = false
				end
			end
		end
		button.Image = UnMuteImage
		songmuted = true
		print("unmuted")
	end
end


local function changeSong()
	if musicfolder:FindFirstChild("sound"..songnumber.Value) and songnumber.Value ~= lastsongnumber then
		musicfolder:FindFirstChild("sound"..songnumber.Value+1):Play()
		songnumber.Value += 1
		print("next song: song "..songnumber.Value)
	else
		musicfolder:FindFirstChild("sound1"):Play()
		songnumber.Value = 1
		print("reached the end, restarting")
	end
end


button.MouseButton1Down:Connect(mute)


for i, v in musicfolder:GetChildren() do 
	if v:IsA("Sound") then 
		v.Ended:Connect(changeSong)
	end
end
--[[
Hi Cap! I have high respect for your attempt to code in a second language,
given French is your mother-tongue. Hopefully this script works good for you,
it should as long as you keep the following things in mind:

Any time you add a new song to the list, following the given naming convention:
(sound4, sound5, sound6, etc.)

This script will automatically loop through all songs in order, and when it reaches
the end, it will start over from the beginning

That should be it, I hope your English keeps improving

]]

Also, all the audios should have their volume set to the same value(in this case 0.2) not 0, with only song1 playing. Try this and see if it works

1 Like

the script works but it’s only when a player joins my game and sound 1 is over, well he can’t hear the next music

Ok, please, this is important, make sure the version you’re using is this one: Guys how can i do a music gui - #56 by 700000002

And make sure of the following things:

All audio’s volume are set to a non-zero value

The music folder only has the audios and an IntValue named “song” and nothing more

That the second sound is written exactly as “sound2”

(Important)That you have checked the output for prints to see if it says “next song” after sound1 ends.

If you check all these things and it still does not work, I may have to send you a model containing all the objects

Hey, is it working? If not, I’ll post a model containing the system I made in it’s entirety (which definitely works; I’m using it right now)

I used a another model for this btu thank you !

Tell me how it works