local V=require(script.Parent.Settings)if V.UseGlobalBackgroundMusic==false and V.UseMusicZones==false then error("\067\105\110\100\101\114\105\110\103\'\115 \066\071\077 \101\114\114\111\114\058 \089\111\117 \104\097\118\101 \100\105\115\097\098\108\101\100 \098\111\116\104 \071\108\111\098\097\108 \066\097\099\107\103\114\111\117\110\100 \077\117\115\105\099 \097\110\100 \077\117\115\105\099 \090\111\110\101\115\046 \089\111\117 \109\117\115\116 \099\104\097\110\103\101 \097\116 \108\101\097\115\116 \111\110\101 \111\102 \116\104\101\115\101 \115\101\116\116\105\110\103\115 \116\111 \'\116\114\117\101\'\046")return end local B="\091\049\093 \071\108\111\098\097\108 \066\097\099\107\103\114\111\117\110\100 \077\117\115\105\099"local G="\091\050\093 \066\097\099\107\103\114\111\117\110\100 \077\117\115\105\099 \090\111\110\101\115"local F=Instance.new("\070\111\108\100\101\114")F.Name="\067\105\110\100\101\114\105\110\103\066\071\077"script.Parent.Settings.Parent=F script.LocalBackgroundMusic.Parent=game.StarterPlayer.StarterPlayerScripts local K=Instance.new("\070\111\108\100\101\114")local E=Instance.new("\070\111\108\100\101\114",K)E.Name="\077\117\115\105\099\090\111\110\101\115"local L=Instance.new("\070\111\108\100\101\114",K)L.Name="\071\108\111\098\097\108\077\117\115\105\099"if V.UseMusicZones==true then local V=script.Parent:FindFirstChild(G)or game.ReplicatedStorage:FindFirstChild(G)or workspace:FindFirstChild(G)or game:FindFirstChild(G,true)if V then for V,B in pairs(V:GetChildren())do if B:IsA("\077\111\100\101\108")and B:FindFirstChild("\077\117\115\105\099")then B.Parent=E end end else error("\067\105\110\100\101\114\105\110\103\'\115 \066\071\077 \101\114\114\111\114\058 \089\111\117\114 \098\097\099\107\103\114\111\117\110\100 \109\117\115\105\099 \122\111\110\101\115 \102\111\108\100\101\114 \099\111\117\108\100 \110\111\116 \098\101 \102\111\117\110\100\033 \089\111\117 \109\097\121 \104\097\118\101 \100\101\108\101\116\101\100\047\114\101\110\097\109\101\100 \116\104\101 \111\114\105\103\105\110\097\108 \102\111\108\100\101\114\046 \073\116 \115\104\111\117\108\100 \098\101 \110\097\109\101\100\058 "..G)return end end if V.UseGlobalBackgroundMusic==true then local V=script.Parent:FindFirstChild(B)or game.ReplicatedStorage:FindFirstChild(B)or workspace:FindFirstChild(B)or game:FindFirstChild(B,true)if V then for V,B in pairs(V:GetChildren())do if B:IsA("\083\111\117\110\100")then B.Parent=L end end else error("\067\105\110\100\101\114\105\110\103\'\115 \066\071\077 \101\114\114\111\114\058 \089\111\117\114 \103\108\111\098\097\108 \098\097\099\107\103\114\111\117\110\100 \109\117\115\105\099 \102\111\108\100\101\114 \099\111\117\108\100 \110\111\116 \098\101 \102\111\117\110\100\033 \089\111\117 \109\097\121 \104\097\118\101 \100\101\108\101\116\101\100\047\114\101\110\097\109\101\100 \116\104\101 \111\114\105\103\105\110\097\108 \102\111\108\100\101\114\046 \073\116 \115\104\111\117\108\100 \098\101 \110\097\109\101\100\058 "..B)return end end if V.UseGlobalBackgroundMusic==true and#L:GetChildren()==0 then warn("\067\105\110\100\101\114\105\110\103\'\115 \066\071\077 \119\097\114\110\105\110\103\058 \089\111\117\114 \103\108\111\098\097\108 \098\097\099\107\103\114\111\117\110\100 \109\117\115\105\099 \102\111\108\100\101\114 \105\115 \099\111\109\112\108\101\116\101\108\121 \101\109\112\116\121\059 \110\111 \109\117\115\105\099 \119\105\108\108 \098\101 \112\108\097\121\101\100 \102\114\111\109 \116\104\101\114\101\046")end if V.UseMusicZones==true and#E:GetChildren()==0 then warn("\067\105\110\100\101\114\105\110\103\'\115 \066\071\077 \119\097\114\110\105\110\103\058 \089\111\117\114 \098\097\099\107\103\114\111\117\110\100 \109\117\115\105\099 \122\111\110\101\115 \102\111\108\100\101\114 \105\115 \099\111\109\112\108\101\116\101\108\121 \101\109\112\116\121\059 \110\111 \109\117\115\105\099 \119\105\108\108 \098\101 \112\108\097\121\101\100 \102\114\111\109 \116\104\101\114\101\046")end K.Name="\077\117\115\105\099\070\111\108\100\101\114"K.Parent=F local q=0 function recurse(V)for V,B in pairs(V:GetChildren())do q=q+1 recurse(B)end end recurse(K)local c=Instance.new("\073\110\116\086\097\108\117\101",F)c.Name="\079\098\106\101\099\116\067\111\117\110\116"c.Value=q F.Parent=game.ReplicatedStorage script.Parent:Destroy()


local settings = require(script.Parent.Settings)

if settings.UseGlobalBackgroundMusic == false and settings.UseMusicZones == false then
	error("Cindering's BGM error: You have disabled both Global Background Music and Music Zones. You must change at least one of these settings to 'true'.")
	return
end

local name1 = "[1] Global Background Music"
local name2 = "[2] Background Music Zones"

local container = Instance.new("Folder")
container.Name = "CinderingBGM"

script.Parent.Settings.Parent = container

script.LocalBackgroundMusic.Parent = game.StarterPlayer.StarterPlayerScripts

local music = Instance.new("Folder")
local zones = Instance.new("Folder",music)
zones.Name = "MusicZones"
local global = Instance.new("Folder",music)
global.Name = "GlobalMusic"

if settings.UseMusicZones == true then
	local folder = script.Parent:FindFirstChild(name2) or game.ReplicatedStorage:FindFirstChild(name2) or workspace:FindFirstChild(name2) or game:FindFirstChild(name2,true) -- never know where someone might accidentally drag that folder...
	
	if folder then
		for _,model in pairs(folder:GetChildren()) do
			if (model:IsA("Model") and model:FindFirstChild("Music")) then
				model.Parent = zones
			end
		end
	else
		error("Cindering's BGM error: Your background music zones folder could not be found! You may have deleted/renamed the original folder. It should be named: "..name2)
		return
	end
end

if settings.UseGlobalBackgroundMusic == true then
	local folder = script.Parent:FindFirstChild(name1) or game.ReplicatedStorage:FindFirstChild(name1) or workspace:FindFirstChild(name1) or game:FindFirstChild(name1,true)
	
	if folder then
		for _,v in pairs(folder:GetChildren()) do
			if v:IsA("Sound") then
				v.Parent = global
			end
		end
	else
		error("Cindering's BGM error: Your global background music folder could not be found! You may have deleted/renamed the original folder. It should be named: "..name1)
		return
	end
end

if settings.UseGlobalBackgroundMusic == true and #global:GetChildren() == 0 then
	warn("Cindering's BGM warning: Your global background music folder is completely empty; no music will be played from there.")
end
if settings.UseMusicZones == true and #zones:GetChildren() == 0 then
	warn("Cindering's BGM warning: Your background music zones folder is completely empty; no music will be played from there.")
end

music.Name = "MusicFolder"
music.Parent = container

local count = 0
function recurse(instance)
	for _,v in pairs(instance:GetChildren()) do
		count = count + 1
		recurse(v)
	end
end
recurse(music)
local val = Instance.new("IntValue",container)
val.Name = "ObjectCount"
val.Value = count

container.Parent = game.ReplicatedStorage

script.Parent:Destroy()
