for K,r in pairs(animNames)do animTable[K]={}animTable[K].count=0 animTable[K].totalWeight=0 local N=script:FindFirstChild(K)if N~=nil then local r=1 for N,m in pairs(N:GetChildren())do animTable[K][r]={}animTable[K][r].anim=m local F=m:FindFirstChild("\087\101\105\103\104\116")if F==nil then animTable[K][r].weight=1 else animTable[K][r].weight=F.Value end animTable[K].count=animTable[K].count+1 animTable[K].totalWeight=animTable[K].totalWeight+animTable[K][r].weight r=r+1 end end if animTable[K].count<=0 then for r,N in pairs(r)do animTable[K][r]={}animTable[K][r].anim=Instance.new("\065\110\105\109\097\116\105\111\110")animTable[K][r].anim.Name=K animTable[K][r].anim.AnimationId=N.id animTable[K][r].weight=N.weight animTable[K].count=animTable[K].count+1 animTable[K].totalWeight=animTable[K].totalWeight+N.weight end end end
-- Setup animation objects
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
