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
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
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
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!
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
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