What do you want to achieve? I want to make a playlist GUI that allows you to rewind, mute, and skip songs that you don’t like. In this post, the main issue is the button to skip songs.
What is the issue? Since I have never actually coded this thing before I am clueless on how to actually program it. Here’s my code (most likely not what’s causing this)
task.wait(2)
while true do
for num, song in songs do
song:Play()
muteButton.Activated:Connect(function()
if muted == false then
muted = true
mute()
elseif muted == true then
muted = false
unMute()
end
end)
skipButton.Activated:Connect(function()
skip(song)
end)
songDisplayerText.Text = song.Name
song.Ended:Wait(3)
end
end
Don’t worry about the mute button that works very well.
What solutions have you tried so far? Don’t ask why but I tried this monstrosity:
local function skip(song)
local songPlaybackRegion = song.PlaybackRegion
songPlaybackRegion = NumberRange.new((song.TimeLength - 1), 60000)
local previousVolume = song.Volume
song.Volume = 0
print(song.TimeLength)
song:Stop()
wait()
song:Play()
song.Ended:Connect(function()
song.Volume = previousVolume
end)
end
I know it’s a work of art
If you can help me solve this please reply down below!
Okay this is a lot for something that can be simple
the structure of your songs must either be
A list of songs inside a SoundGroup
1 single sound object that changes SoundIds
If you want a rewind feature just do what the skip function does but instead its
SoundPosition = 0
local lastPlayed
local currentSound
local muted = false
--- put the button functions outside the loop because memory leaks and theres just no reason for them to be in the loop
muteButton.Activated:Connect(function()
if not muted then
muted = true
mute() -- youll need to edit the mute functions to use currentSound as the sound object (or use soundgroups)
else
muted = false
unMute()
end
end)
skipButton.Activated:Connect(function()
if currentSound ~= nil then
Sound.TimePosition = Sound.TimeLength
end
end)
task.spawn(function()
while true do
local Sound = songs[math.random(1, #songs)] -- Table of your songs
if Sound ~= LastSound then -- Guaranteeing that the same song doesnt play twice
songDisplayerText.Text = Sound.Name
Sound:Play()
LastSound = Sound
currentSound = Sound
Sound.Ended:Wait() -- Plays new song immediately once the song finishes **cant be looped
currentSound = nil
end
end
end)