So i was wrong oh well.
Well in your code it shows %clientbrickcount then you just make %brickcount. The %brickcount has nothing to do with the previous code. So if this did not help sorry and please correct me if i am wrong.