local soundsFolder = script.Parent.Sounds local dataStores = game:GetService("DataStoreService") local saveData = dataStores:GetDataStore("SaveData") game.Players.PlayerAdded:Connect(function(plr) local soundData = saveData:GetAsync(plr.UserId) 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)