--Variables
Song = script.Parent.Song
SongName = script.Parent.BottomSection.SongName
Album = script.parent.BottomSection.AlbumCover
local ContentProvider = game:GetService("ContentProvider")
times = script.Parent.BottomSection.Length
Music = {
{
['song'] = 'Bryson Tiller - Been That Way',
['artist'] = 'Bryson Tille',
['itemId'] = 'rbxassetid://313095574',
['length'] = 50
},
{
['song'] = 'Drake - God\'s Plan',
['artist'] = 'Drake',
['itemId'] = 'rbxassetid://1375384985',
['length'] = 50
},
{
['song'] = 'Bryson Tiller - You Got It',
['artist'] = 'Brsyon Tiller',
['itemId'] = 'rbxassetid://977685900',
['length'] = 50
}
}
local getRandomSongId = function()
return Music[math.random(1,#Music)]["itemId"]
end
Song.SoundId = getRandomSongId()
for _,v in pairs(Music)do
if
v.itemId == Song.SoundId then
print("Found the correct array")
SongName.Text = v.song
end
end
--time length
while true do
times.Text = Song.TimePosition
wait(0.00000009)
end
Song.Ended:connect(function()
print("hi") --This part right here. When the song ends, nothing actually prints.
end)
So I have this music player I'm working on, but when I test the ended event, it doesn't actually work. Is it because you have to press play and you can press pause? Or is the event just not working? Is there a solution? What do I do?

1 comment
Wrap your while true do from L48 in a spawn(function() end)