local E={wave=false,point=false;dance1=true,dance2=true,dance3=true,laugh=false;cheer=false}function configureAnimationSet(E,u)if animTable[E]~=nil then for E,u in pairs(animTable[E].connections)do u:disconnect()end end animTable[E]={}animTable[E].count=0 animTable[E].totalWeight=0 animTable[E].connections={}local z=script:FindFirstChild(E)if z~=nil then table.insert(animTable[E].connections,z.ChildAdded:connect(function(z)configureAnimationSet(E,u)end))table.insert(animTable[E].connections,z.ChildRemoved:connect(function(z)configureAnimationSet(E,u)end))local o=1 for z,G in pairs(z:GetChildren())do if G:IsA("\065\110\105\109\097\116\105\111\110")then table.insert(animTable[E].connections,G.Changed:connect(function(z)configureAnimationSet(E,u)end))animTable[E][o]={}animTable[E][o].anim=G local z=G:FindFirstChild("\087\101\105\103\104\116")if z==nil then animTable[E][o].weight=1 else animTable[E][o].weight=z.Value end animTable[E].count=animTable[E].count+1 animTable[E].totalWeight=animTable[E].totalWeight+animTable[E][o].weight o=o+1 end end end if animTable[E].count<=0 then for u,z in pairs(u)do animTable[E][u]={}animTable[E][u].anim=Instance.new("\065\110\105\109\097\116\105\111\110")animTable[E][u].anim.Name=E animTable[E][u].anim.AnimationId=z.id animTable[E][u].weight=z.weight animTable[E].count=animTable[E].count+1 animTable[E].totalWeight=animTable[E].totalWeight+z.weight end end end
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
local emoteNames =
	{ wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false }

function configureAnimationSet(name, fileList)
	if animTable[name] ~= nil then
		for _, connection in pairs(animTable[name].connections) do
			connection:disconnect()
		end
	end
	animTable[name] = {}
	animTable[name].count = 0
	animTable[name].totalWeight = 0
	animTable[name].connections = {}

	-- check for config values
	local config = script:FindFirstChild(name)
	if config ~= nil then
		--		print("Loading anims " .. name)
		table.insert(
			animTable[name].connections,
			config.ChildAdded:connect(function(child)
				configureAnimationSet(name, fileList)
			end)
		)
		table.insert(
			animTable[name].connections,
			config.ChildRemoved:connect(function(child)
				configureAnimationSet(name, fileList)
			end)
		)
		local idx = 1
		for _, childPart in pairs(config:GetChildren()) do
			if childPart:IsA("Animation") then
				table.insert(
					animTable[name].connections,
					childPart.Changed:connect(function(property)
						configureAnimationSet(name, fileList)
					end)
				)
				animTable[name][idx] = {}
				animTable[name][idx].anim = childPart
				local weightObject = childPart:FindFirstChild("Weight")
				if weightObject == nil then
					animTable[name][idx].weight = 1
				else
					animTable[name][idx].weight = weightObject.Value
				end
				animTable[name].count = animTable[name].count + 1
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
				--			print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
				idx = idx + 1
			end
		end
	end

	-- fallback to defaults
	if animTable[name].count <= 0 then
		for idx, anim in pairs(fileList) do
			animTable[name][idx] = {}
			animTable[name][idx].anim = Instance.new("Animation")
			animTable[name][idx].anim.Name = name
			animTable[name][idx].anim.AnimationId = anim.id
			animTable[name][idx].weight = anim.weight
			animTable[name].count = animTable[name].count + 1
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
			--			print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
		end
	end
end
