script.Parent.Paused.Changed:connect(function()if script.Parent.Paused.Value==true then for Y,p in pairs(script.Parent:GetChildren())do if p:IsA("\083\111\117\110\100")then p.Looped=true p:Pause()end end else for Y,p in pairs(script.Parent:GetChildren())do if p:IsA("\083\111\117\110\100")then if script.Parent.Stopped.Value~=true then p:Play()end p.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 Y,p in pairs(script.Parent:GetChildren())do if p:IsA("\083\111\117\110\100")then p:Stop()wait()end end end end)script.Parent.Track.Changed:connect(function()if debounce==false then debounce=true local Y=songs[script.Parent.Track.Value]script.Parent.TName.Value=Y.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 Y=script.RadioGui.Draggable.Menu Y.CanvasSize=UDim2.new(0,0,0,15*#songs)for p,r in pairs(songs)do for Y,p in pairs(r:GetChildren())do content:Preload(p.Id.Value)end local b=Instance.new("\084\101\120\116\066\117\116\116\111\110",Y)b.Name=r.Name b.Size=UDim2.new(1,0,0,15)b.Position=UDim2.new(0,5,0,(p-1)*15)b.BackgroundTransparency=1 b.Text=r.Name b.TextColor3=Color3.new(1,1,1)b.FontSize=Enum.FontSize.Size10 b.TextXAlignment=Enum.TextXAlignment.Left end function play()script.Parent.Stopped.Value=false script.Parent.Paused.Value=false local Y=songs[script.Parent.Track.Value]script.Parent.TName.Value=Y.Name local p={}for Y,r in pairs(Y:GetChildren())do sound.Name=r.Name sound.SoundId=r.Id.Value sound.Volume=0 sound.Pitch=0 table.insert(p,sound)end wait()for Y,r in pairs(Y:GetChildren())do if script.Parent.Stopped.Value~=true then local b=p[Y]b:Stop()b.Pitch=r.Pitch.Value b.Volume=script.Parent.Volume.Value/10 local h=r.Duration.Value b:Play()local D=tick()local g=tick()-D repeat wait(.001)if script.Parent.Paused.Value==true then D=tick()-g else g=tick()-D end until g>=h or script.Parent.Stopped.Value==true b:Stop()end end if script.Parent.Stopped.Value~=true then if script.Parent.Autoplay.Value==true then local Y=script.Parent.Track.Value+1 if Y>#songs then Y=1 end script.Parent.Track.Value=Y 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)
