Advertisement
Stefanuk12

Musics

Mar 20th, 2020
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. local HS = game:GetService('HttpService')
  2. local musicTable = HS:JSONDecode(game:HttpGetAsync('https://epicgameronmylevel696969.000webhostapp.com/Data.json'))
  3.  
  4. function testContentDeleted(songid)
  5.     local sound = Instance.new("Sound", game:GetService("Lighting"))
  6.     sound.SoundId = "rbxassetid://"..songid
  7.     sound.Volume = 0
  8.     sound:Play()
  9.     wait(0.1)
  10.     if sound.TimeLength < 0.05 then
  11.         sound:Destroy()    
  12.         return false
  13.     else
  14.         sound:Destroy()    
  15.         return true
  16.     end
  17. end
  18.  
  19. function updateMusicTable()
  20.     for i,v in pairs(musicTable) do
  21.         if testContentDeleted(musicTable[i].SoundId) == false then
  22.             musicTable[i] = nil
  23.         end
  24.     end
  25. end
  26.  
  27. function changeMusicTable(Index, Name, SoundId)
  28.     updateMusicTable()
  29.     if musicTable[Index] then
  30.         if SoundId then
  31.             musicTable[Index].SoundId = SoundId
  32.         end
  33.         if Name then
  34.             musicTable[Index].Name = Name
  35.         end
  36.     end
  37. end
  38.  
  39. function addMusicTable(Name, SoundId)
  40.     updateMusicTable()
  41.     local Index = #musicTable + 1
  42.     musicTable[Index] = {}
  43.     musicTable[Index].Name = Name
  44.     musicTable[Index].SoundId = SoundId
  45. end
  46.  
  47. function removeMusicTable(Index)
  48.     updateMusicTable()
  49.     table.remove(musicTable, Index)
  50. end
  51.  
  52. function getMusic()
  53.     updateMusicTable()
  54.  
  55.     for i=1, #musicTable do
  56.         local namex = musicTable[i].Name
  57.         print("You can play", namex, "- Index =", i)
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement