I'm trying to use sendChat to parse a dice roll and store it as a damage value, which will then be compared to the character's SDC & HP (Palladium). The RandomInteger(20) function works for the attack roll, but since the dice expression isn't nearly as simple for damage, I have been trying to use sendChat. Unfortunately, the sendChat callback is being executed AFTER the code that appends the damage to the powercard. var PS = getAttrByName(userToken.get("represents"), "PS"); if(strengthDamage == "Y") { strDamage = PS - 15; if(strDamage < 0) {strDamage = 0;} } log(strDamage); var maDamage = getAttrByName(userToken.get("represents"), "DAM") var dmgRollResult; var damage = 0; sendChat("API", "/roll " + atk_damage + " + " + strDamage + " + " + maDamage, function(ops){ log(ops[0]); dmgRollResult = JSON.parse(ops[0].content); log(dmgRollResult.total); damage = dmgRollResult.total; }); var ignoreAR = parseInt(arIgnore); var targetPersonalAR = getAttrByName(targetToken.get("represents"), "PERSONAL_AR"); var targetPersonalSDC = getAttrByName(targetToken.get("represents"), "PERSONAL_SDC"); var targetRoboticAR = getAttrByName(targetToken.get("represents"), "ROBOTIC_AR"); var targetRoboticSDC = getAttrByName(targetToken.get("represents"), "ROBOTIC_SDC"); var targetArmorAR = getAttrByName(targetToken.get("represents"), "ARMOR_AR"); var targetArmorSDC = getAttrByName(targetToken.get("represents"), "ARMOR_SDC"); var targetBarrierAR = getAttrByName(targetToken.get("represents"),"BARRIER_AR"); var targetBarrierSDC = getAttrByName(targetToken.get("represents"),"BARRIER_SDC"); var targetHP = getAttrByName(targetToken.get("represents"), "HP") var bypassBarrier = true; var bypassArmor = true; var bypassRobotic = true; var bypassPersonal = true; var diceRoll = randomInteger(20); var output = "!power --leftsub|" + userToken.get("name") + " --rightsub|" + targetToken.get("name"); var totalRoll = diceRoll + atk_bonus + bonus; if(diceRoll == 1) { output = output + " --Die Roll|Natural 1! Automatic Failure!"; } else if(diceRoll == 20) { output = output + " --Die Roll|Natural 20! Automatic Critical!"; damage = damage * 2; } else { output = output + " --Die Roll|" + diceRoll.toString(); } var totalDamage = damage; output = output + " --Total Damage|" + totalDamage.toString(); log(output); my totalDamage variable is still at 0 when it is logged, and after log(output) fires as the last line, the log(dmgRollResult.total) line fires. I've read Brian's solution but since that was about a year ago I was hoping there was an answer that would be limited to this sendChat command rather than restructuring the entire function.