Problems with music GUI datastore

I have been scripting an advanced music player, It works like it should except when you rejoin the songs
on your playlist do not get loaded by datastore.

There are no errors.
Here is the server handler code where the datastores are scripted:

script.txt (2.9 KB)

Client handler if needed:
script2.txt (772 Bytes)

Help would be appreciated,
have a good day!

Is the datastore returning no data, or is there data but its not displaying properly?

Also I recommend reading this: Data Stores | Roblox Creator Documentation

I am not sure, I believe it is returning nothing.

Well don’t guess, a good way to find out is to just print the returned value and see what it holds

Is your datastore a table, or just string?

It is a table that stores sound IDs

It doesnt return it, there is no print

Maybe try to use pcall()
In your server script.


Source

local soundsFolder = script.Parent.Sounds
local dataStores = game:GetService("DataStoreService")
local saveData = dataStores:GetDataStore("SaveData")

game.Players.PlayerAdded:Connect(function(plr)
	local soundData;
    local suc, er = pcall(function()
        soundData = saveData:GetAsync(plr.UserId)
    end)

    if (er) then -- Checks if theres an error
        error(er) -- Prints the error to the output.
    end 
	for i, v in pairs(soundData) do
		local value = Instance.new("IntValue", soundsFolder)
		value.Name = v
		local c = script.Template:Clone()
		c.Parent = script.Parent.MainFrame.ListLayout.List
		c.Ident.Text = v
		c.ID.Value = v
		c.Sound.SoundId = "rbxassetid://"..c.ID.Value
		local songInfo = game:GetService("MarketplaceService"):GetProductInfo(v)
		c.SongName.Text = songInfo.Name
		script.Parent.SongAmount.Value += 1
		wait()
		script.Parent.MainFrame.SongNumber.Text = "{"..script.Parent.SongAmount.Value.."} Songs"
		c.Name = script.Parent.SongAmount.Value
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local soundTable = {}
	for i, v in pairs(script.Parent.Sounds:GetChildren()) do
		table.insert(soundTable, v.Name)
	end
	saveData:SetAsync(plr.UserId, soundTable)
end)

wait(1)
script.Parent.Remotes.DeleteClient.OnServerEvent:Connect(function(plr, music)
	local typeFrame = script.Parent.MainFrame.TypeId
	local value = script.Parent.Sounds:FindFirstChild(music.Sound.SoundId)
	if value then
		value:Destroy()
	end
	wait()
	music:Destroy()
	script.Parent.SongAmount.Value = script.Parent.SongAmount.Value - 1
	wait()
	script.Parent.MainFrame.SongNumber.Text = "{"..script.Parent.SongAmount.Value.."} Songs"
end)

script.Parent.Remotes.AddClient.OnServerEvent:Connect(function(plr, songAmount, text)
	local mainFrame = script.Parent.MainFrame
	local typeFrame = script.Parent.MainFrame.TypeId
	local list = script.Parent.MainFrame.ListLayout.List
	
	if text ~= "" and tonumber(text) ~= nil then
		local c = script.Template:Clone()
		c.Parent = list
		c.Ident.Text = text
		c.ID.Value = text
		c.Sound.SoundId = "rbxassetid://"..c.ID.Value
		local value = Instance.new("IntValue")
		value.Parent = script.Parent.Sounds
		value.Name = text
		local songInfo = game:GetService("MarketplaceService"):GetProductInfo(text)
		c.SongName.Text = songInfo.Name
		songAmount.Value += 1
		wait()
		script.Parent.MainFrame.SongNumber.Text = "{"..songAmount.Value.."} Songs"
		c.Name = songAmount.Value
	end
	wait(0.1)
	text = ""
end)

script.Parent.Remotes.LoopClient.OnServerEvent:Connect(function(plr, sound)
	if sound.Looped == false then
		sound.Looped = true
	else
		sound.Looped = false
	end
end)

script.Parent.Remotes.PlayClient.OnServerEvent:Connect(function(plr, sound)
	local songInfo = game:GetService("MarketplaceService"):GetProductInfo(sound.Parent.ID.Value)
	script.Parent.Corner.SongName.Text = songInfo.Name
	script.Parent.Corner.Publisher.Text = songInfo.Creator.Name
	script.Parent.Remotes.PlayServer:FireClient(plr, sound)
	script.Parent.SoundPlayed.Value = sound
end)

There’s no output error or warning.

Try to print the data.
print(soundData)
Put it before the for loop.

for some reason it doesnt print

Are you trying in Studio or in Game?

studio, for some reason it doesnt even print at the start of the function

like if i try to print(“lol”) it doesnt work

Probably your script is disabled.

How would I fix it? the rest of it works

Click on the script, then go to properties then you will see Disabled if its checked then uncheck it.

its not disabled, i have no idea what is doing thi

Is there any loop in starting of the script?

no, what i sent is the full script