script.Parent.Paused.Changed:connect(function()if script.Parent.Paused.Value==true then for I,j in pairs(script.Parent:GetChildren())do if j:IsA("\083\111\117\110\100")then j.Looped=true j:Pause()end end else for I,j in pairs(script.Parent:GetChildren())do if j:IsA("\083\111\117\110\100")then if script.Parent.Stopped.Value~=true then j:Play()end j.Looped=false end end end end)script.Parent.Stopped.Changed:connect(function()if script.Parent.Stopped.Value==true then script.Parent.Paused.Value=false for I,j in pairs(script.Parent:GetChildren())do if j:IsA("\083\111\117\110\100")then j:Stop()wait()end end end end)script.Parent.Track.Changed:connect(function()if debounce==false then debounce=true local I=songs[script.Parent.Track.Value]script.Parent.TName.Value=I.Name if script.Parent.Stopped.Value~=true then script.Parent.Stopped.Value=true wait()script.Parent.Play.Value=not script.Parent.Play.Value end debounce=false end end)script.Parent.IdPlay.Changed:connect(function()if script.Parent.IdPlay.Value~=""then script.Parent.Stopped.Value=true sound.SoundId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..script.Parent.IdPlay.Value sound.Volume=script.Parent.Volume.Value/10 sound.Pitch=1 sound.Looped=true script.Parent.TName.Value=((game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")):GetProductInfo(script.Parent.IdPlay.Value)).Name wait()script.Parent.Stopped.Value=false sound:Play()end end)local I=script.RadioGui.Draggable.Menu I.CanvasSize=UDim2.new(0,0,0,15*#songs)for j,b in pairs(songs)do for I,j in pairs(b:GetChildren())do content:Preload(j.Id.Value)end local o=Instance.new("\084\101\120\116\066\117\116\116\111\110",I)o.Name=b.Name o.Size=UDim2.new(1,0,0,15)o.Position=UDim2.new(0,5,0,(j-1)*15)o.BackgroundTransparency=1 o.Text=b.Name o.TextColor3=Color3.new(1,1,1)o.FontSize=Enum.FontSize.Size10 o.TextXAlignment=Enum.TextXAlignment.Left end function play()script.Parent.Stopped.Value=false script.Parent.Paused.Value=false local I=songs[script.Parent.Track.Value]script.Parent.TName.Value=I.Name local j={}for I,b in pairs(I:GetChildren())do sound.Name=b.Name sound.SoundId=b.Id.Value sound.Volume=0 sound.Pitch=0 table.insert(j,sound)end wait()for I,b in pairs(I:GetChildren())do if script.Parent.Stopped.Value~=true then local o=j[I]o:Stop()o.Pitch=b.Pitch.Value o.Volume=script.Parent.Volume.Value/10 local u=b.Duration.Value o:Play()local K=tick()local t=tick()-K repeat wait(.001)if script.Parent.Paused.Value==true then K=tick()-t else t=tick()-K end until t>=u or script.Parent.Stopped.Value==true o:Stop()end end if script.Parent.Stopped.Value~=true then if script.Parent.Autoplay.Value==true then local I=script.Parent.Track.Value+1 if I>#songs then I=1 end script.Parent.Track.Value=I else script.Parent.Stopped.Value=true end end end script.Parent.Play.Changed:connect(function()play()end)
--------------------------
script.Parent.Paused.Changed:connect(function()
	if script.Parent.Paused.Value == true then
		for i, v in pairs(script.Parent:GetChildren()) do
			if v:IsA("Sound") then
				v.Looped = true
				v:Pause()
			end
		end
	else
		for i, v in pairs(script.Parent:GetChildren()) do
			if v:IsA("Sound") then
				if script.Parent.Stopped.Value ~= true then
					v:Play()
				end
				v.Looped = false
			end
		end
	end
end)
script.Parent.Stopped.Changed:connect(function()
	if script.Parent.Stopped.Value == true then
		script.Parent.Paused.Value = false
		for i, v in pairs(script.Parent:GetChildren()) do
			if v:IsA("Sound") then
				v:Stop()
				wait()
			end
		end
	end
end)
script.Parent.Track.Changed:connect(function()
	if debounce == false then
		debounce = true
		local song = songs[script.Parent.Track.Value]
		script.Parent.TName.Value = song.Name
		if script.Parent.Stopped.Value ~= true then
			script.Parent.Stopped.Value = true
			wait()
			script.Parent.Play.Value = not script.Parent.Play.Value
		end
		debounce = false
	end
end)
script.Parent.IdPlay.Changed:connect(function()
	if script.Parent.IdPlay.Value ~= "" then
		script.Parent.Stopped.Value = true
		sound.SoundId = "http://www.roblox.com/asset/?id=" .. script.Parent.IdPlay.Value
		sound.Volume = script.Parent.Volume.Value / 10
		sound.Pitch = 1
		sound.Looped = true
		script.Parent.TName.Value = game:GetService("MarketplaceService")
			:GetProductInfo(script.Parent.IdPlay.Value).Name
		wait()
		script.Parent.Stopped.Value = false
		sound:Play()
	end
end)
local rgui = script.RadioGui.Draggable.Menu
rgui.CanvasSize = UDim2.new(0, 0, 0, 15 * #songs)
for i, v in pairs(songs) do
	for b, a in pairs(v:GetChildren()) do
		content:Preload(a.Id.Value)
	end
	local button = Instance.new("TextButton", rgui)
	button.Name = v.Name
	button.Size = UDim2.new(1, 0, 0, 15)
	button.Position = UDim2.new(0, 5, 0, (i - 1) * 15)
	button.BackgroundTransparency = 1
	button.Text = v.Name
	button.TextColor3 = Color3.new(1, 1, 1)
	button.FontSize = Enum.FontSize.Size10
	button.TextXAlignment = Enum.TextXAlignment.Left
end
function play()
	script.Parent.Stopped.Value = false
	script.Parent.Paused.Value = false
	local song = songs[script.Parent.Track.Value]
	script.Parent.TName.Value = song.Name
	local playing = {}
	for i, v in pairs(song:GetChildren()) do
		sound.Name = v.Name
		sound.SoundId = v.Id.Value
		sound.Volume = 0
		sound.Pitch = 0
		table.insert(playing, sound)
	end
	wait()
	for i, v in pairs(song:GetChildren()) do
		if script.Parent.Stopped.Value ~= true then
			local a = playing[i]
			a:Stop()
			a.Pitch = v.Pitch.Value
			a.Volume = script.Parent.Volume.Value / 10
			local dur = v.Duration.Value
			a:Play()
			local t = tick()
			local run = tick() - t
			repeat
				wait(0.001)
				if script.Parent.Paused.Value == true then
					t = tick() - run
				else
					run = tick() - t
				end
			until run >= dur or script.Parent.Stopped.Value == true
			a:Stop()
		end
	end
	if script.Parent.Stopped.Value ~= true then
		if script.Parent.Autoplay.Value == true then
			local n = script.Parent.Track.Value + 1
			if n > #songs then
				n = 1
			end
			script.Parent.Track.Value = n
		else
			script.Parent.Stopped.Value = true
		end
	end
end
script.Parent.Play.Changed:connect(function()
	play()
end)
