Hi all I am trying to write a script that searches a repeating section (skills) of a character sheet for a specific skill, then return the level of that skill (which is an auto-calculated field on the character sheet due to the sheer number of parameters involved). I can use sendChat to calculate the actual value of the field (in the getSkillLevel function) and that works fine, and the value is passed to the FindSkill function fine, but instead of having FindSkill return that value, it returns a -1 as if it never executed the WHILE loop. I put a log statement to check the value of the var slevel before the break statement, and the log shows the correct value. A log statement to check slevel before the return statement always shows its value to be -1. I'm not terribly experienced in Javascript, so I might be missing something simple. Anybody have any thoughts? Here are my functions: function getSkillLevel(charName, n) { return new Promise(resolve => { sendChat('API', '[[@{'+charName+'|repeating_skills_$'+n+'_level}]]', ops => { let total = ops[0].inlinerolls[0].results.total; resolve(total); }); }); } function findSkill(charId,charName,searchName) { var n = 0; var sName = 'sname'; var slevel = -1 while (sName != '' && n < 100) { sName = getAttrByName(charId,'repeating_skills_$'+n+'_name'); if (sName === searchName) { getSkillLevel(charName, n).then((result) => { slevel = result; }); break; } n++; } return slevel; };