Advertisement
BobMe

Some Music Gui thing

Aug 23rd, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. -- Made by Memo1332/Poin Test for.. some reason
  2.  
  3. -- Idk, I guess I got bored lol
  4.  
  5. -- Objects
  6.  
  7. local Musics = Instance.new("ScreenGui")
  8. local OuterFrame = Instance.new("Frame")
  9. local Pause = Instance.new("TextButton")
  10. local Play = Instance.new("TextButton")
  11. local Stop = Instance.new("TextButton")
  12. local Replay = Instance.new("TextButton")
  13. local CurrentTime = Instance.new("TextLabel")
  14. local EndTime = Instance.new("TextLabel")
  15. local Ent = Instance.new("TextBox")
  16. local Music = Instance.new("Sound")
  17. local BarFolder = Instance.new("Folder")
  18. local Bar = Instance.new("Frame")
  19. local Slide = Instance.new("Frame")
  20. local Barhit = Instance.new("TextButton")
  21.  
  22. -- Properties
  23.  
  24. Musics.Name = "Music"
  25. Musics.Parent = game.Players.LocalPlayer.PlayerGui
  26. Musics.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  27.  
  28. OuterFrame.Name = "OuterFrame"
  29. OuterFrame.Parent = Musics
  30. OuterFrame.AnchorPoint = Vector2.new(1, 1)
  31. OuterFrame.BackgroundColor3 = Color3.new(0, 0, 0)
  32. OuterFrame.BackgroundTransparency = 0.5
  33. OuterFrame.Position = UDim2.new(1, -10, 1, -10)
  34. OuterFrame.Size = UDim2.new(0.300000012, 0, 0.100000001, 0)
  35. OuterFrame.SizeConstraint = Enum.SizeConstraint.RelativeXX
  36.  
  37. Music.Parent = OuterFrame
  38. Music.Volume = 2
  39. Music.Looped = true
  40.  
  41. BarFolder.Name = "Bar"
  42. BarFolder.Parent = OuterFrame
  43.  
  44. Bar.Name = "Bar"
  45. Bar.Parent = BarFolder
  46. Bar.AnchorPoint = Vector2.new(0.5, 0)
  47. Bar.BackgroundColor3 = Color3.new(1, 1, 1)
  48. Bar.Position = UDim2.new(0.5, 0, 0.460000008, 0)
  49. Bar.Size = UDim2.new(0.899999976, 0, 0.0299999993, 0)
  50.  
  51. Slide.Name = "Slide"
  52. Slide.Parent = Bar
  53. Slide.AnchorPoint = Vector2.new(0.5, 0.5)
  54. Slide.BackgroundColor3 = Color3.new(0.968628, 0, 1)
  55. Slide.BorderSizePixel = 0
  56. Slide.Position = UDim2.new(0, 0, 0.5, 0)
  57. Slide.Size = UDim2.new(1.5, 0, 6, 0)
  58. Slide.SizeConstraint = Enum.SizeConstraint.RelativeYY
  59.  
  60. Barhit.Name = "Barhit"
  61. Barhit.Parent = BarFolder
  62. Barhit.AnchorPoint = Vector2.new(0.5, 0.5)
  63. Barhit.BackgroundColor3 = Color3.new(1, 1, 1)
  64. Barhit.BackgroundTransparency = 1
  65. Barhit.Position = UDim2.new(0.5, 0, 0.479999989, 0)
  66. Barhit.Size = UDim2.new(0.949999988, 0, 0.200000003, 0)
  67. Barhit.ZIndex = 2
  68. Barhit.Font = Enum.Font.SourceSans
  69. Barhit.Text = ""
  70. Barhit.TextColor3 = Color3.new(0, 0, 0)
  71. Barhit.TextSize = 14
  72.  
  73. Pause.Name = "Pause"
  74. Pause.Parent = OuterFrame
  75. Pause.AnchorPoint = Vector2.new(0.5, 0)
  76. Pause.BackgroundColor3 = Color3.new(1, 0, 0.952941)
  77. Pause.BackgroundTransparency = 0.69999998807907
  78. Pause.Position = UDim2.new(0.5, 0, 0.63499999, 0)
  79. Pause.Size = UDim2.new(0.102763534, 0, 0.307033986, 0)
  80. Pause.Visible = false
  81. Pause.Font = Enum.Font.SourceSans
  82. Pause.Text = " ▌▌"
  83. Pause.TextColor3 = Color3.new(1, 1, 1)
  84. Pause.TextSize = 14
  85.  
  86. Play.Name = "Play"
  87. Play.Parent = OuterFrame
  88. Play.AnchorPoint = Vector2.new(0.5, 0)
  89. Play.BackgroundColor3 = Color3.new(1, 0, 0.952941)
  90. Play.BackgroundTransparency = 0.69999998807907
  91. Play.Position = UDim2.new(0.5, 0, 0.63499999, 0)
  92. Play.Size = UDim2.new(0.102763534, 0, 0.307033986, 0)
  93. Play.Font = Enum.Font.SourceSans
  94. Play.Text = "▷"
  95. Play.TextColor3 = Color3.new(1, 1, 1)
  96. Play.TextScaled = true
  97. Play.TextSize = 14
  98. Play.TextWrapped = true
  99.  
  100. Stop.Name = "Stop"
  101. Stop.Parent = OuterFrame
  102. Stop.AnchorPoint = Vector2.new(0.5, 0)
  103. Stop.BackgroundColor3 = Color3.new(1, 0, 0.952941)
  104. Stop.BackgroundTransparency = 0.69999998807907
  105. Stop.Position = UDim2.new(0.643000007, 0, 0.63499999, 0)
  106. Stop.Size = UDim2.new(0.102763534, 0, 0.307033986, 0)
  107. Stop.Font = Enum.Font.SourceSans
  108. Stop.Text = "□"
  109. Stop.TextColor3 = Color3.new(1, 1, 1)
  110. Stop.TextScaled = true
  111. Stop.TextSize = 14
  112. Stop.TextWrapped = true
  113. Stop.TextYAlignment = Enum.TextYAlignment.Top
  114.  
  115. Replay.Name = "Replay"
  116. Replay.Parent = OuterFrame
  117. Replay.AnchorPoint = Vector2.new(0.5, 0)
  118. Replay.BackgroundColor3 = Color3.new(1, 0, 0.952941)
  119. Replay.BackgroundTransparency = 0.69999998807907
  120. Replay.Position = UDim2.new(0.356999993, 0, 0.63499999, 0)
  121. Replay.Size = UDim2.new(0.102763534, 0, 0.307033986, 0)
  122. Replay.Font = Enum.Font.SourceSans
  123. Replay.Text = "◁◁"
  124. Replay.TextColor3 = Color3.new(1, 1, 1)
  125. Replay.TextScaled = true
  126. Replay.TextSize = 14
  127. Replay.TextWrapped = true
  128.  
  129. CurrentTime.Name = "CurrentTime"
  130. CurrentTime.Parent = OuterFrame
  131. CurrentTime.AnchorPoint = Vector2.new(0.5, 0)
  132. CurrentTime.BackgroundColor3 = Color3.new(0.968628, 0, 1)
  133. CurrentTime.BackgroundTransparency = 1
  134. CurrentTime.Position = UDim2.new(0.159999996, 0, 0.63499999, 0)
  135. CurrentTime.Size = UDim2.new(0.230000004, 0, 0.307000011, 0)
  136. CurrentTime.Font = Enum.Font.SourceSans
  137. CurrentTime.Text = "0:00"
  138. CurrentTime.TextColor3 = Color3.new(1, 1, 1)
  139. CurrentTime.TextScaled = true
  140. CurrentTime.TextSize = 14
  141. CurrentTime.TextWrapped = true
  142.  
  143. EndTime.Name = "EndTime"
  144. EndTime.Parent = OuterFrame
  145. EndTime.AnchorPoint = Vector2.new(0.5, 0)
  146. EndTime.BackgroundColor3 = Color3.new(0.968628, 0, 1)
  147. EndTime.BackgroundTransparency = 1
  148. EndTime.Position = UDim2.new(0.839999974, 0, 0.63499999, 0)
  149. EndTime.Size = UDim2.new(0.230000004, 0, 0.307000011, 0)
  150. EndTime.Font = Enum.Font.SourceSans
  151. EndTime.Text = "0:00"
  152. EndTime.TextColor3 = Color3.new(1, 1, 1)
  153. EndTime.TextScaled = true
  154. EndTime.TextSize = 14
  155. EndTime.TextWrapped = true
  156.  
  157. Ent.Name = "Ent"
  158. Ent.Parent = OuterFrame
  159. Ent.AnchorPoint = Vector2.new(0.5, 0)
  160. Ent.BackgroundColor3 = Color3.new(1, 1, 1)
  161. Ent.BackgroundTransparency = 1
  162. Ent.Position = UDim2.new(0.5, 0, -0.0149999997, 10)
  163. Ent.Size = UDim2.new(0.839999974, 0, 0.314999998, 0)
  164. Ent.Font = Enum.Font.SourceSans
  165. Ent.PlaceholderText = ""
  166. Ent.Text = ""
  167. Ent.TextColor3 = Color3.new(1, 1, 1)
  168. Ent.TextScaled = true
  169. Ent.TextSize = 14
  170. Ent.TextWrapped = true
  171.  
  172. -- Scripts
  173.  
  174. rbx = game:GetService("MarketplaceService")
  175. user = game:GetService("UserInputService")
  176. local mouse = game.Players.LocalPlayer:GetMouse()
  177. local drag = false
  178. local startpos = nil
  179. local start = nil
  180. local play = false
  181.  
  182. Ent.FocusLost:Connect(function(ent)
  183. if ent == true then
  184. local txt = Ent
  185. local sound = Music
  186. if txt.Text:sub(1,6):lower() == "pitch/" then
  187. sound.Pitch = tonumber(txt.Text:sub(7))
  188. txt.Text = rbx:GetProductInfo(tonumber(sound.SoundId:sub(14))).Name
  189. elseif txt.Text:sub(1,7):lower() == "volume/" then
  190. sound.Volume = tonumber(txt.Text:sub(8))
  191. txt.Text = rbx:GetProductInfo(tonumber(sound.SoundId:sub(14))).Name
  192. else
  193. local product = rbx:GetProductInfo(tonumber(txt.Text))
  194. if product.Name ~= nil then
  195. sound.SoundId = "rbxassetid://"..txt.Text
  196. sound.TimePosition = 0
  197. sound.Pitch = 1
  198. sound:Play()
  199. Pause.Visible = true
  200. Play.Visible = false
  201. txt.Text = product.Name
  202. end
  203. end
  204. else
  205. local sound = Music
  206. if sound.SoundId ~= "" then
  207. local txt = Ent
  208. txt.Text = rbx:GetProductInfo(tonumber(sound.SoundId:sub(14))).Name
  209. end
  210. end
  211. end)
  212.  
  213. Play.MouseButton1Click:Connect(function()
  214. if drag == false then
  215. local sound = Music
  216. sound:Resume()
  217. Pause.Visible = true
  218. Play.Visible = false
  219. end
  220. end)
  221.  
  222. Pause.MouseButton1Click:Connect(function()
  223. local sound = Music
  224. sound:Pause()
  225. Pause.Visible = false
  226. Play.Visible = true
  227. end)
  228.  
  229. Stop.MouseButton1Click:Connect(function()
  230. if drag == false then
  231. local sound = Music
  232. sound:Stop()
  233. sound.TimePosition = 0
  234. Pause.Visible = false
  235. Play.Visible = true
  236. end
  237. end)
  238.  
  239. Replay.MouseButton1Click:Connect(function()
  240. if drag == false then
  241. local sound = Music
  242. sound.TimePosition = 0
  243. sound:Play()
  244. Pause.Visible = true
  245. Play.Visible = false
  246. end
  247. end)
  248.  
  249. Barhit.MouseButton1Down:Connect(function(x,y)
  250. local sound = Music
  251. if sound.Playing == true then
  252. play = true
  253. else
  254. play = false
  255. end
  256. sound:Pause()
  257. Pause.Visible = false
  258. Play.Visible = true
  259. -----------
  260. startpos = x
  261. drag = true
  262. start = sound.TimePosition
  263. end)
  264.  
  265. Barhit.MouseButton1Up:Connect(function()
  266. drag = false
  267. start = nil
  268. startpos = nil
  269. if play == true then
  270. local sound = Music
  271. sound:Resume()
  272. Pause.Visible = true
  273. Play.Visible = false
  274. end
  275. end)
  276.  
  277. function dec(number)
  278. local h = tostring(number)
  279.  
  280. local thenumber = 0
  281. for i=1,100 do
  282. if string.sub(h,i,i) == "." then
  283. thenumber = i
  284. break
  285. end
  286. end
  287.  
  288. number = string.sub(h,1,thenumber - 1)
  289. number = tonumber(number)
  290. return (number)
  291. end
  292.  
  293. function clock(seconds)
  294. -- Military Clock Converter (but better)
  295.  
  296. local minutes = 0
  297.  
  298. while seconds >= 60 do
  299. minutes = minutes + 1
  300. seconds = seconds - 60
  301. end
  302.  
  303. --Line of strings
  304. seconds = dec(seconds)
  305. if seconds < 10 then
  306. seconds = "0"..tostring(seconds)
  307. end
  308.  
  309. return (minutes..":"..seconds)
  310. end
  311.  
  312. coroutine.resume(coroutine.create(function()
  313. --[[while wait() do
  314. local sound = Music
  315. OuterFrame.CurrentTime.Text = clock(sound.TimePosition)
  316. OuterFrame.EndTime.Text = clock(sound.TimeLength)
  317. end]]
  318. end))
  319.  
  320. game:GetService("RunService").RenderStepped:Connect(function()
  321. if drag == true then
  322. local loc = user:GetMouseLocation()
  323. local sum = loc.X-startpos
  324. local sound = Music
  325. if (start + sum/3) >= 0 and (start + sum/3) <= sound.TimeLength then
  326. sound.TimePosition = start + sum/3
  327. end
  328. end
  329.  
  330. local sound = Music
  331. OuterFrame.CurrentTime.Text = clock(sound.TimePosition)
  332. OuterFrame.EndTime.Text = clock(sound.TimeLength)
  333.  
  334. local sound = Music
  335. local bar = Bar.Slide
  336. if sound.TimePosition ~= 0 and sound.TimeLength ~= 0 then
  337. bar.Position = UDim2.new(sound.TimePosition/sound.TimeLength,0,0.5,0)
  338. else
  339. bar.Position = UDim2.new(0,0,0.5,0)
  340. end
  341. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement