Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mps = game:GetService("MarketplaceService")
- local bg = script.Parent
- local playBtn = bg:WaitForChild("PlayButton")
- local loopingBtn = bg:WaitForChild("LoopingToggle")
- local timePos = bg:WaitForChild("MusicTimePos")
- local volumeToggleBtn = bg:WaitForChild("VolumeToggle")
- local volumeUp = bg:WaitForChild("VolumeUp")
- local volumeDown = bg:WaitForChild("VolumeDown")
- local volumeAmount = bg:WaitForChild("VolumeAmount")
- local musicName = bg:WaitForChild("MusicName")
- local musicOwner = bg:WaitForChild("MusicOwner")
- local musicInputBox = bg:WaitForChild("MusicInput")
- local music = bg:WaitForChild("Music")
- local isLooping = false
- local isPlaying = false
- local isMuted = false
- local currentVolume = 10
- local minVolume = 0
- local maxVolume = 10
- musicName.Text = ""
- musicOwner.Text = ""
- volumeAmount.Text = "10"
- timePos.Text = "00:00"
- musicInputBox.FocusLost:Connect(function()
- local input = musicInputBox.Text
- local success, info = pcall(mps.GetProductInfo, mps, input)
- if success and info.AssetTypeId == 3 then
- music:Stop()
- isPlaying = false
- playBtn.Image = game.ReplicatedStorage.Decals.Play.Texture
- music.SoundId = "rbxassetid://" .. input
- musicName.Text = info.Name
- musicOwner.Text = " by " .. info.Creator.Name
- end
- end)
- playBtn.MouseButton1Click:Connect(function()
- if isPlaying then
- isPlaying = false
- playBtn.Image = game.ReplicatedStorage.Decals.Play.Texture
- music:Pause()
- else
- isPlaying = true
- playBtn.Image = game.ReplicatedStorage.Decals.Pause.Texture
- music:Resume()
- end
- end)
- loopingBtn.MouseButton1Click:Connect(function()
- if isLooping then
- isLooping = false
- music.Looped = false
- loopingBtn.ImageColor3 = Color3.fromRGB(95, 95, 95)
- else
- isLooping = true
- music.Looped = true
- loopingBtn.ImageColor3 = Color3.fromRGB(255, 255, 255)
- end
- end)
- volumeToggleBtn.MouseButton1Click:Connect(function()
- if isMuted then
- isMuted = false
- volumeToggleBtn.ImageColor3 = Color3.fromRGB(95, 95, 95)
- music.Volume = currentVolume / 10
- else
- isMuted = true
- volumeToggleBtn.ImageColor3 = Color3.fromRGB(255, 255, 255)
- music.Volume = 0
- end
- end)
- volumeUp.MouseButton1Click:Connect(function()
- isMuted = false
- volumeToggleBtn.ImageColor3 = Color3.fromRGB(95, 95, 95)
- currentVolume = math.clamp(currentVolume + 1, minVolume, maxVolume)
- music.Volume = currentVolume / 10
- volumeAmount.Text = currentVolume
- end)
- volumeDown.MouseButton1Click:Connect(function()
- isMuted = false
- volumeToggleBtn.ImageColor3 = Color3.fromRGB(95, 95, 95)
- currentVolume = math.clamp(currentVolume - 1, minVolume, maxVolume)
- music.Volume = currentVolume / 10
- volumeAmount.Text = currentVolume
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- local musicTimePos = math.floor(music.TimePosition)
- local musicTimePosSecs = musicTimePos % 60
- local musicTimePosMins = math.floor(musicTimePos / 60)
- if string.len(musicTimePosSecs) < 2 then musicTimePosSecs = "0" .. musicTimePosSecs end
- if string.len(musicTimePosMins) < 2 then musicTimePosMins = "0" .. musicTimePosMins end
- timePos.Text = musicTimePosMins .. ":" .. musicTimePosSecs
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement