Hi all, Here's a script created by Nick O. and updated by Aaron, but I have a little issue with it on("chat:message", function(msg) { if (msg.type == "api" && msg.content.indexOf("!customSpellbook") == 0){ var args = msg.content.split(/\s+/); var spellName = args[1].toLowerCase(); var spellLevel = Number(args[2]); var tokenid = msg.selected[0]._id; var token = getObj("graphic",tokenid); var charID = token.get("represents"); var tokenName = token.get("name"); switch(spellName){ case "projectilemagique": Projectilemagique(spellLevel); break; case "rayonardent": Rayonardent(spellLevel,tokenName); break; } sendChat("API",`!modbattr --charid ${charID} --lvl${spellLevel}_slots_expended|-1`); } }); function Projectilemagique(spellLevel){ var numberOfDarts = spellLevel + 2; var dartOutput = ""; /* for(counter=1;counter<=numberOfDarts;counter++){ dartOutput+=`{{Dart ${counter} = [[1d4+1]]}}`; } var outputMessage = `&{template:default} {{name=Projectile Magique}} ${dartOutput}`; */ let dartTotal = []; for(counter=1;counter<=numberOfDarts;counter++){ dartTotal.push(`[[1d4+1]]`); dartOutput+=`{{Projectile ${counter} = $[[${counter-1}]]}}`; } var outputMessage = `&{template:default} {{name=Projectile Magique}}[[${dartTotal.join('+')}]]${dartOutput} {{Total=$[[${numberOfDarts}]]}}`; sendChat("Résultat",outputMessage); } function Rayonardent(spellLevel,tokenName){ var numberOfRays = 3 + (spellLevel-2); var rayOutput = ""; if(spellLevel<2){ sendChat("CustomSpellbook","Rayon Ardent doit être lancé au niveau 2 minimum"); return; } for (counter=1;counter<=numberOfRays;counter++){ rayOutput+=`{{Rayon${counter} Att [[1d20+@{${tokenName}|spell_attack_bonus} ]]=[[2d6]] Dégats feu}}`; } var outputMessage = `&{template:default} {{name=Rayon Ardent}} ${rayOutput}`; sendChat("Résultat",outputMessage); } the magic missile part works fine, but on the scorching ray part, the damages don't take any account of the critical rolls. If any of the rays does a critical hit roll, the damages should roll twice too, and i don't know how to deal with the code to deal these crit damages. Could anyone help me ? thanks.