Advertisement
HowToRoblox

BoomboxServer

Nov 12th, 2020 (edited)
2,434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local plr = script.Parent.Parent.Parent
  2.  
  3.  
  4. local re = script.Parent:WaitForChild("BoomboxRE")
  5.  
  6. local music = script.Parent.Handle:WaitForChild("Music")
  7.  
  8.  
  9. local mps = game:GetService("MarketplaceService")
  10.  
  11.  
  12. local ds = game:GetService("DataStoreService")
  13.  
  14. local musicData = ds:GetDataStore("MusicData")
  15. local musicList = musicData:GetAsync("MusicList - " .. plr.UserId) or {}
  16.  
  17. re:FireClient(plr, musicList)
  18.  
  19.  
  20. re.OnServerEvent:Connect(function(plr, id)
  21.    
  22.     local success, isAudio = pcall(mps.GetProductInfo, mps, id)
  23.     if not success or isAudio.AssetTypeId ~= 3 then return end
  24.  
  25.     local musicName = mps:GetProductInfo(id).Name
  26.    
  27.    
  28.     music.SoundId = "rbxassetid://" .. id
  29.     music:Play()
  30.    
  31.    
  32.     musicList[id] = musicName
  33.     musicData:SetAsync("MusicList - " .. plr.UserId, musicList)
  34.    
  35.     re:FireClient(plr, musicList)
  36. end)
  37.  
  38. script.Parent.Equipped:Connect(function()
  39.     re:FireClient(plr, musicList)
  40. end)
  41. script.Parent.Unequipped:Connect(function()
  42.     music:Stop()
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement