I have already looked on the Roblox Wiki and stuff but I couldn't find out how to do this but I am making a music player and want custom song titles, artist names, and album art but whenever I try and pull data from my dictionary, it doesn't seem to grab any data at all. There are no errors in the output.
--Variables local Players = game.Players local Player = Players.LocalPlayer local Sound = script.Parent.Music local GUI = Player.PlayerGui.MusicGui local ArtGUI = GUI.RadioGUI.Art.AlbumArt local TitleGUI = GUI.RadioGUI.Info.Title local ArtistGUI = GUI.RadioGUI.Info.Artist SongList = { { ID = 7029024726, Title = "Bloom", Artist = "Throttle", ArtID = 7377998210 }, { ID = 7024154355, Title = "Feels Like Love", Artist = "Laszlo", ArtID = 7378871754 }, { ID = 1061409802, Title = "Kodokushi", Artist = "Kyoto Black, Mihka!", ArtID = 7378895447 }, { ID = 2409526081, Title = "Only Way Out (Blyzo remix)", Artist = "Madeon , Blyzo", ArtID = 7378912620 }, } --end song list while wait() do Sound:Stop() if not Sound.IsPlaying then local SongChosen = SongList[math.random(1,#SongList)] Sound.SoundId = "rbxassetid://"..SongChosen["ID"] TitleGUI.Text = SongChosen["Title"] ArtistGUI.Text = SongChosen["Artist"] ArtGUI.Image = "rbxassetid://"..SongChosen["ArtID"] Sound:Play() wait(Sound.TimeLength) end end
Looks like your songs are not loading due to your while wait() do loop.
while wait() do Sound:Stop() if not Sound.IsPlaying then local SongChosen = SongList[math.random(1,#SongList)] Sound.SoundId = "rbxassetid://"..SongChosen["ID"] TitleGUI.Text = SongChosen["Title"] ArtistGUI.Text = SongChosen["Artist"] ArtGUI.Image = "rbxassetid://"..SongChosen["ArtID"] Sound:Play() wait(Sound.TimeLength) end end
This works fine for people that have had time for the songs to download but not for anyone new where it would simply skip to the next song. Which will also not have enough time to load causing nothing to play.
To get round this i would add one little check:
while Sound.IsLoaded == false do wait()end -- wait for things to load!
This would wait for the sound to load before continuing onto the next song. Beware!: this might still break if you get the SongID wrong or the Song isn't available or simply deleted!.
While wait do loop in full:
while wait() do Sound:Stop() if not Sound.IsPlaying then local SongChosen = SongList[math.random(1,#SongList)] Sound.SoundId = "rbxassetid://"..SongChosen["ID"] TitleGUI.Text = SongChosen["Title"] ArtistGUI.Text = SongChosen["Artist"] ArtGUI.Image = "rbxassetid://"..SongChosen["ArtID"] Sound:Play() while Sound.IsLoaded == false do wait()end -- wait for things to load! wait(Sound.TimeLength) end end
Hope this helps!
p.s sorry for the bad grammar as I'm operating on very little sleep lol >_>