--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'm trying to use the Ended event. For some reason, when the song actually ends, it doesn't print anything and nothing happens. Why is this? Is the ended event broken? Am I using it wrong?
EDIT: Someone gave me answer but the event doesn't work. I was having a dumb moment using the event but when I use it properly, it still doesn't work? I have a play button for the music to actually play. That's in another script. Can that be a problem?

4 comments
Another problem might be on line 37 your if statement is on a different line then what your checking. Just move the v.itemId == Song.SoundId then up 1 line
I know this is late...like very late
Change connect to Connect maybe that will work.
This post is so old lol. I've learned about the Song.Ended.