for E,R in pairs(animNames)do animTable[E]={}animTable[E].count=0 animTable[E].totalWeight=0 local U=script:FindFirstChild(E)if U~=nil then local R=1 for U,A in pairs(U:GetChildren())do animTable[E][R]={}animTable[E][R].anim=A local J=A:FindFirstChild("\087\101\105\103\104\116")if J==nil then animTable[E][R].weight=1 else animTable[E][R].weight=J.Value end animTable[E].count=animTable[E].count+1 animTable[E].totalWeight=animTable[E].totalWeight+animTable[E][R].weight R=R+1 end end if animTable[E].count<=0 then for R,U in pairs(R)do animTable[E][R]={}animTable[E][R].anim=Instance.new("\065\110\105\109\097\116\105\111\110")animTable[E][R].anim.Name=E animTable[E][R].anim.AnimationId=U.id animTable[E][R].weight=U.weight animTable[E].count=animTable[E].count+1 animTable[E].totalWeight=animTable[E].totalWeight+U.weight end end end

for name, fileList in pairs(animNames) do 
	animTable[name] = {}
	animTable[name].count = 0
	animTable[name].totalWeight = 0
		
	-- check for config values
	local config = script:FindFirstChild(name)
	if (config ~= nil) then
		--		print("Loading anims " .. name)
		local idx = 1
		for _, childPart in pairs(config:GetChildren()) do
			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
		
	-- 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
	