Ok so the goal of this script worker is to calculate how much experience has been spent in our homebrew game. The system of the game is you spend experience to raise the attributes in the following pattern (starting at 10 in each attribute): 10 experience to get to 20, 20 experience to get to 30, 30 experience to get to 40, etc. As you can imagine doing this by hand is pretty time consuming, and it's hard to check if characters are spending an appropriate amount of experience. So I want to calculate the experience cost for each of the 5 attributes (strength, vitality, agility, finesse, and spirit) and add them together into a total in the spentexp container. So we wrote the for loop out below in mathlabs (the math works in mathlabs), converted it to javascript, and plugged it in but it fails to update. I've been trying for about a week and a half to get it to kick anything but I've hit a wall and can't figure out what is wrong with it. Any help would be awesome, I'm still learning roll20 too so feedback/guidance is also appreciated. <!-- Experience containers --> <input type="number" name='attr_experience' value='10'> <span name='attr_spentexp'></span> <input type="number" name='attr_remainingexperience' value='(@{experience}-@{spentexperience})' disabled='true'> <!-- Attributes --> Might <input type="number" name='attr_might' value='10'> <br> Vitality <input type="number" name='attr_vitality' value='10'> <br> Agility <input type="number" name='attr_agility' value='10'> <br> Finesse <input type="number" name='attr_finesse' value='10'> <br> Spirit <input type="number" name='attr_spirit' value='10'> <script type="text/worker"> // EXPERIENCE CALCULATOR WIP const stats = ['might','vitality','agility','finesse','spirit']; stats.forEach(function (stat) { on("change:" + stat + " sheet:opened", function () { getAttrs([stat], function (values) { //This gets the value of the attribute's score. var stat_score = parseInt(values[stat], 10)||0; var exp_total = 0; for(var x = 1; x < 5; x++) { //Increments the cost of raising the attribute's score. var y = stat_score; var n = 0; for(var i=1; i < y/10; i++) { for(var j=1; j < 10 ; j++) { exp_total += n ; //Adds all of the experience together, excluding the remainder. }; n += 1; }; exp_total += ((y- (n*10)) * n); //Adds the remainder from the singles digit to the cost. (If a stat has a value of 96, this adds the cost of the 6.) }; }); }); setAttrs({ "spentexp" : exp_total }); }); </script>