How to add to a variable outside a for loop, inside a for loop

It sounds confusing, but I am trying to add up a folders childrens values to a variable outside a for loop. As shown below. But “multi” is still 0 in the end, when that values are more than 0.

local mult = 0
			
for i,v in pairs(childs) do
	if v.Equipped == true then
		mult += v.Multiplier1.Value
	end
end

Is v.Equipped true? Throw a print in there that shows you mult every step.

local mult = 0
			
for i,v in pairs(childs) do
	if v.Equipped == true then
		mult += v.Multiplier1.Value
        print(mult)
	end
end

If it prints then you are adding the wrong number most likely, if it doesn’t either childs is an empty list or the if statement is failing.

I forgot to put if v.Equipped.Value == true

1 Like