Hello folks, I am dabbling with a script (to use with the Beacon Sheets). This is what I have so far, but for some reason, I cannot add the tokens to the turn order. Please help, and thank you! So far, I have only tried to implement the Initiative part of the script. // ------------------------------- // D&D 2024 Rolls For Combat // Using async getSheetItem() // Command: !rfc // ------------------------------- on("chat:message", async (msg) => { if (msg.type !== "api") return; if (!msg.content.startsWith("!rfc")) return; const args = msg.content.split(/\s+/).slice(1); // remove "!rfc" const flags = args.filter(a => a.startsWith("--")); const params = args.filter(a => !a.startsWith("--")); // words after flags (e.g. weapon name) // Default behavior if no flags given if (flags.length === 0) { await RFC_GroupInitiative(msg); return; } // Use first flag as command (you can support more later) const cmd = flags[0].toLowerCase(); switch (cmd) { case "--init": await RFC_GroupInitiative(msg); break; case "--strsave": await RFC_SaveRoll(msg, "strength_save_bonus", "Strength Save"); break; case "--dexsave": await RFC_SaveRoll(msg, "dexterity_save_bonus", "Dexterity Save"); break; case "--consave": await RFC_SaveRoll(msg, "constitution_save_bonus", "Constitution Save"); break; case "--wissave": await RFC_SaveRoll(msg, "wisdom_save_bonus", "Wisdom Save"); break; case "--chaosave": await RFC_SaveRoll(msg, "charisma_save_bonus", "Charisma Save"); break; case "--strcheck": await RFC_CheckRoll(msg, "strength_mod", "Strength Check"); break; case "--dexcheck": await RFC_CheckRoll(msg, "dexterity_mod", "Dexterity Check"); break; case "--help": RFC_ShowHelp(msg); break; default: sendChat("RollsForCombat", `/w "${msg.who}" Unknown RFC command: ${cmd}`); } async function RFC_GroupInitiative(msg){ let results = []; // Process each selected token for (const sel of msg.selected) { const token = getObj("graphic", sel._id); if (!token) continue; const charId = token.get("represents"); if (!charId) continue; const character = getObj("character", charId); if (!character) continue; // --- ASYNC GET INITIATIVE BONUS --- let initBonus = 0; try { const val = await getSheetItem(charId, "initiative_bonus"); initBonus = parseInt(val) || 0; } catch (err) { log("Error getting initiative_bonus: " + err); } // Roll initiative const roll = randomInteger(20); const total = roll + initBonus; results.push({ id: token.id, name: token.get("name") || character.get("name"), bonus: initBonus, roll: roll, total: total }); } // Sort highest → lowest results.sort((a, b) => b.total - a.total); // Build output let text = `<b>📜 Group Initiative</b><br><br>`; results.forEach(r => { text += `<b>${r.name}</b>: <code>${r.roll}</code> + ${r.bonus} = <b>${r.total}</b><br>`; }); sendChat("Group Init", text); // OPTIONAL: Write to Turn Tracker var turnorder; //NOTE: We check to make sure that the turnorder isn't just an empty string first. If it is treat it like an empty array. if(Campaign().get("turnorder") == "") turnorder = []; else turnorder = JSON.parse(Campaign().get("turnorder")); //Add a new custom entry to the end of the turn order. results.forEach(r => { turnorder.push({ id: r.id, pr: r.total, custom: "", _pageid: Campaign().get("playerpageid") }); }); Campaign().set("turnorder", JSON.stringify(turnorder)); } });