Advertisement
HowToRoblox

BoomboxClient

Nov 12th, 2020
3,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. local boombox = script.Parent
  2. local re = boombox:WaitForChild("BoomboxRE")
  3.  
  4.  
  5. local plr = game.Players.LocalPlayer
  6.  
  7. local clonedGui
  8.  
  9.  
  10. boombox.Equipped:Connect(function()
  11.    
  12.     clonedGui = game.ReplicatedStorage.BoomboxGui:Clone()
  13.     clonedGui.Parent = plr.PlayerGui
  14.    
  15.     clonedGui.MusicIDInput.FocusLost:Connect(function(enterPressed)
  16.        
  17.         if not enterPressed then return end
  18.        
  19.         local inputtedID = clonedGui.MusicIDInput.Text
  20.         clonedGui.MusicIDInput.Text = ""
  21.        
  22.         re:FireServer(inputtedID)
  23.     end)
  24. end)
  25.  
  26. boombox.Unequipped:Connect(function()
  27.    
  28.     clonedGui:Destroy()
  29. end)
  30.  
  31.  
  32. re.OnClientEvent:Connect(function(musicList)
  33.    
  34.     repeat wait() until clonedGui
  35.    
  36.     if not musicList then return end
  37.    
  38.     clonedGui.ListOfMusic:ClearAllChildren()
  39.    
  40.     local uiGridLayout = Instance.new("UIGridLayout")
  41.     uiGridLayout.FillDirection = Enum.FillDirection.Vertical
  42.     uiGridLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  43.     uiGridLayout.CellSize = UDim2.new(1, 0, 0.072, 0)
  44.    
  45.     uiGridLayout.Parent = clonedGui.ListOfMusic
  46.    
  47.    
  48.     for musicId, musicName in pairs(musicList) do
  49.        
  50.         local musicInfoClone = script.MusicInfo:Clone()
  51.         musicInfoClone.MusicName.Text = musicName
  52.        
  53.         musicInfoClone.Parent = clonedGui.ListOfMusic
  54.        
  55.         musicInfoClone.PlayButton.MouseButton1Click:Connect(function()
  56.            
  57.             re:FireServer(musicId)
  58.         end)
  59.     end
  60. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement