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