Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How Can I Pull Data From Dictionary?

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

1 answer

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 >_>

2 comments

0

Unfortunately this didn't work... I made sure all the sound ids were valid and working and still no fix. I have a feeling it could be that its a table within a table and that I'm grabbing something not valid but I wouldn't know how to have a work around for that because I havent seen any info on it.

0

i've given you mail on roblox :)

This discussion is preserved as it was. New answers, comments, and votes are closed.