local N=require(game.ReplicatedStorage:WaitForChild("\082\101\115\111\117\114\099\101\115"))while not N.Loaded do(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:Wait()end local T={}local g={}local r=Random.new()local s=nil function Shuffle()local J=N.Functions.CloneTable(T)for N,T in ipairs(g)do if N then else break end for N,g in ipairs(J)do if N then else break end if g==T then table.remove(J,N)break end end end local d=J[r:NextInteger(1,#J)]if not d then return end s=N.Sound.PlayMusic(d,.5,4,nil,false)if 4<=#g then table.remove(g,1)end table.insert(g,d)end function Clear()N.Sound.StopMusic(1)s=nil g={}end local J=nil function Set(g)local r=N.Directory.Worlds[g]T=r.music Clear()if J then(N.Functions.Tween(J,{2},{Volume=0})).Completed:Connect(function()J:Stop()J:Destroy()end)end local s=r.ambience if s then if s~=0 then J=N.Sound.Play(s,script,1,.3,nil,nil,true)end end end;(N.Signal.Fired("\087\111\114\108\100 \067\104\097\110\103\101\100")):Connect(function(N)Set(N)end)task.defer(function()while true do if N.Settings.MusicEnabled and#T>0 then if not s or s.TimeLength-.5<=s.TimePosition and s.IsLoaded then Shuffle()end elseif not N.Settings.MusicEnabled and s then Clear()end N.Heartbeat(5)end end)


local v1 = require(game.ReplicatedStorage:WaitForChild("Resources"));
while not v1.Loaded do
	game:GetService("RunService").Heartbeat:Wait();
end;
local u1 = {};
local u2 = {};
local u3 = Random.new();
local u4 = nil;
function Shuffle()
	local v2 = v1.Functions.CloneTable(u1);

		for v3, v4 in ipairs(u2) do
		if v3 then

		else
			break;
		end;

			for v6, v7 in ipairs(v2) do
			if v6 then

			else
				break;
			end;
			if v7 == v4 then
				table.remove(v2, v6);
				break;
			end;		
		end;	
	end;
	local v9 = v2[u3:NextInteger(1, #v2)];
	if not v9 then
		return;
	end;
	u4 = v1.Sound.PlayMusic(v9, 0.5, 4, nil, false);
	if 4 <= #u2 then
		table.remove(u2, 1);
	end;
	table.insert(u2, v9);
end;
function Clear()
	v1.Sound.StopMusic(1);
	u4 = nil;
	u2 = {};
end;
local u5 = nil;
function Set(p1)
	local v10 = v1.Directory.Worlds[p1];
	u1 = v10.music;
	Clear();
	if u5 then
		v1.Functions.Tween(u5, { 2 }, {
			Volume = 0
		}).Completed:Connect(function()
			u5:Stop();
			u5:Destroy();
		end);
	end;
	local l__ambience__11 = v10.ambience;
	if l__ambience__11 then
		if l__ambience__11 ~= 0 then
			u5 = v1.Sound.Play(l__ambience__11, script, 1, 0.3, nil, nil, true);
		end;
	end;
end;
v1.Signal.Fired("World Changed"):Connect(function(p2)
	Set(p2);
end);
task.defer(function()
	while true do
		if v1.Settings.MusicEnabled and #u1 > 0 then
			if not u4 or u4.TimeLength - 0.5 <= u4.TimePosition and u4.IsLoaded then
				Shuffle();
			end;
		elseif not v1.Settings.MusicEnabled and u4 then
			Clear();
		end;
		v1.Heartbeat(5);	
	end;
end);

