BobMe

song player

Feb 22nd, 2021 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. -- Instances:
  2.  
  3. local Songs = Instance.new("ScreenGui")
  4. local Frame = Instance.new("Frame")
  5. local Mute = Instance.new("TextButton")
  6. local NowPlaying = Instance.new("TextLabel")
  7.  
  8. --Properties:
  9.  
  10. Songs.Name = "Songs"
  11. Songs.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  12. Songs.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  13. Songs.ResetOnSpawn = false
  14.  
  15. Frame.Parent = Songs
  16. Frame.AnchorPoint = Vector2.new(1, 1)
  17. Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  18. Frame.BackgroundTransparency = 1.000
  19. Frame.Position = UDim2.new(1, 0, 1, 0)
  20. Frame.Size = UDim2.new(0.200000003, 0, 0.150000006, 0)
  21.  
  22. Mute.Name = "Mute"
  23. Mute.Parent = Frame
  24. Mute.AnchorPoint = Vector2.new(1, 1)
  25. Mute.BackgroundColor3 = Color3.fromRGB(255, 0, 251)
  26. Mute.BackgroundTransparency = 0.500
  27. Mute.BorderSizePixel = 0
  28. Mute.Position = UDim2.new(1, -3, 1, -3)
  29. Mute.Size = UDim2.new(0.300000012, 0, 0.200000003, 0)
  30. Mute.Font = Enum.Font.SourceSans
  31. Mute.Text = "Mute"
  32. Mute.TextColor3 = Color3.fromRGB(255, 255, 255)
  33. Mute.TextScaled = true
  34. Mute.TextSize = 14.000
  35. Mute.TextWrapped = true
  36.  
  37. NowPlaying.Name = "NowPlaying"
  38. NowPlaying.Parent = Frame
  39. NowPlaying.AnchorPoint = Vector2.new(0, 1)
  40. NowPlaying.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  41. NowPlaying.BackgroundTransparency = 0.500
  42. NowPlaying.Position = UDim2.new(1.10000002, -3, 0.75, 0)
  43. NowPlaying.Size = UDim2.new(1, 0, 0.449999988, 0)
  44. NowPlaying.Font = Enum.Font.SourceSans
  45. NowPlaying.Text = "Now playing: Garbage truck"
  46. NowPlaying.TextColor3 = Color3.fromRGB(255, 255, 255)
  47. NowPlaying.TextSize = 22.000
  48. script.Parent = owner.PlayerGui
  49. local songlist = {}
  50. muted = false
  51. currentsong = 1
  52. rbx = game:GetService("MarketplaceService")
  53. song = Instance.new("Sound",Songs)
  54. song.Volume = 0.4
  55. lastsong = 0
  56. -- rbx:GetProductInfo().Name
  57. local muted = false
  58. Mute.MouseButton1Click:Connect(function()
  59. if not muted then
  60. muted = true
  61. Mute.BackgroundColor3 = Color3.fromRGB(0,0,0)
  62. Mute.Text = "Unmute"
  63. else
  64. muted = false
  65. Mute.BackgroundColor3 = Color3.fromRGB(255, 0, 251)
  66. Mute.Text = "Mute"
  67. end
  68. end)
  69. local songs = {
  70. 911993485,
  71. 4110953040,
  72. 838005568,
  73. 2217398035,
  74. 1625489737,
  75. 1402202152,
  76. 1045722860,
  77. 1339865767,
  78. 5686389321,
  79. 5630330827,
  80. 5196933474,
  81. 5046738115,
  82. 5523078772,
  83. 961018305,
  84. 895079632,
  85. 4924129997,
  86. 5554411383,
  87. 2522691284,
  88. 4069430993,
  89. 3328634141,
  90. 2654040596,
  91. 4963202696,
  92. 1180273873,
  93. 2482937864,
  94. 1123126733,
  95. 4595789343,
  96. 2393991991,
  97. 5034732210,
  98. 1938554614,
  99. 1591776686,
  100. 3406661902,
  101. 5011189105,
  102. 3315991165,
  103. 1866644818
  104. }
  105.  
  106.  
  107. local function copyarray(original)
  108. local copy = {}
  109. for k, v in pairs(original) do
  110. if type(v) == "table" then
  111. v = copyarray(v)
  112. end
  113. copy[k] = v
  114. end
  115. return copy
  116. end
  117.  
  118. function shufflesongs()
  119. local s = copyarray(songs)
  120. for i,v in pairs(songlist) do
  121. table.remove(songlist,1)
  122. end
  123. for i=1,#s do
  124. local num = math.random(1,#s)
  125. table.insert(songlist,s[num])
  126. table.remove(s,num)
  127. end
  128. end
  129. shufflesongs()
  130. coroutine.resume(coroutine.create(function()
  131. while wait() do
  132. if not muted then
  133. if lastsong ~= songlist[currentsong] then
  134. song.SoundId = "rbxassetid://"..tostring(songlist[currentsong])
  135. song:Play()
  136. lastsong = songlist[currentsong]
  137. NowPlaying.Text = "Now playing: "..rbx:GetProductInfo(songlist[currentsong]).Name
  138. NowPlaying:TweenPosition(UDim2.new(0,-3,0.75,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back,0.7,true)
  139. coroutine.resume(coroutine.create(function()
  140. wait(4)
  141. NowPlaying:TweenPosition(UDim2.new(1.1,-3,0.75,0),Enum.EasingDirection.In,Enum.EasingStyle.Back,0.7,true)
  142. end))
  143. repeat wait(.5) until song.Playing == false or muted
  144. currentsong = currentsong + 1
  145. if currentsong > #songlist then
  146. currentsong = 1
  147. shufflesongs()
  148. end
  149. else
  150. currentsong = currentsong + 1
  151. end
  152. else
  153. song:Stop()
  154. wait(1)
  155. end
  156. end
  157. end))
  158.  
  159. owner.Chatted:Connect(function(msg)
  160. if string.lower(msg) == ";quit" then
  161. Songs:Destroy()
  162. script:Destroy()
  163. end
  164. end)
Add Comment
Please, Sign In to add comment