Is there’s a way to make a skip option for my music script? so every time you click a button it plays the next song.
here’s the script:
local music = {"2529519176", "1333784441", "621227155"}
local sound = script.Parent.Sound
local muted = false
while true do
for i = 1, #music do
sound.SoundId = "rbxassetid://"..music[i]
local Sound = script.Parent.Sound
local id = Sound.SoundId:match("%d+")
local Asset = game:GetService("MarketplaceService"):GetProductInfo(id)
script.Parent.SongName.Text = "Loading Song"
wait(3)
script.Parent.SongName.Text = "Now Playing: "..Asset.Name
sound:Play()
wait(sound.TimeLength)
end
end
Instead of waiting the length, try using the Playing feature of Sounds, so if a song is playing, it can be skipped/doesn’t play another song until it’s done playing. Use RemoteEvents to make Skipping a feature.
while true do
if sound.Playing == false then
local musictoPlay = music[math.random(1, #music)] --Random music
--Play music
end
end
Here. I had just shortened it. (This worked upon testing it in a baseplate.)
while wait() do
if sound.Playing == false then
local musictoPlay = music[math.random(1, #music)] --Random music
sound.SoundId = "rbxassetid://" .. musictoPlay
local Sound = script.Parent.Sound
local id = Sound.SoundId:match("%d+")
local Asset = game:GetService("MarketplaceService"):GetProductInfo(id)
script.Parent.SongName.Text = "Loading Song"
wait(3)
script.Parent.SongName.Text = "Now Playing: "..Asset.Name
sound:Play()
end
end
Edit : To make a Skip button, just change the sound.Playing to false if the Skip is successful.
We’re flooding the thread, just move it to PMs if you have any more issues.
You can:
A. Turn the volume down to 0 if you mute the song
or
B. Make the script check if the music isn’t playing and if the music doesn’t have a paused boolean active