I notice a few issues in your script, so here's a version that should work. It's not as good as using group initiative, and requires you to manually enter how the initiative roll is made (tell us how you roll that, and I can tell you what needs changing). Launch it by typing !addturn , and you can add either sort or sort+ if you want it sorted descending or ascending. /* Syntax select a bunch of tokens, then type one of: !addturn !addturn sort !addturn sort+ The first just adds the selected tokens to the turn tracker the second does that, and sorts them from high to low the last sorts from low to high */ on('ready', function () { 'use strict'; log('======= ADDTURN READY======'); const makeInitRoll = function(init) { // we know init is a number, but roll20 thinks its a string, so convert it. const initscore = +init; // enter a roll function here, using randomInteger const roll = randomInteger(20) + initscore; // return value to loop return roll; }; const buildTurnOrder = function (selected, sort = '') { let turnorder= Campaign().get('turnorder') ? JSON.parse(Campaign().get('turnorder')) : []; selected.forEach(obj => { // check the current object is a token, who is linked to a character const token = getObj(obj._type, obj._id); const init = (!token.get('represents')) ? '' : getAttrByName(token.get('represents'),'initiative'); // for each character token found, where initiative is a number, add to turnorder if('' !== init && !isNaN(init)) { // get actual initiative roll const initRoll = makeInitRoll(init); // need to check if current token is already in turn order const found = turnorder.findIndex(turn => turn.id == token.id); if(-1 === found) { turnorder.push({ id: token.id, pr: initRoll }); } else { turnorder[found] = { id: token.id, pr: initRoll }; } } }); // sort turnorder if needed if(sort) { turnorder = ('+' === sort.slice(-1)) ? turnorder.sort((a,b) => { return a.pr - b.pr; }) : turnorder.sort((a,b) => { return b.pr - a.pr; }); } Campaign().set('turnorder', JSON.stringify(turnorder)); }; on('chat:message', function (msg) { // returns the chat window command entered, all in lowercase. if (!msg.type === 'api') return; let args = msg.content.split(/\s+/); // handle if people accidentally enter two or more spaces if (args[0].toLowerCase() === '!addturn') { const selected = msg.selected; if (!selected) { sendChat('Add Turn', '/w GM No Tokens selected.'); return; //quit if nothing selected } const sort = args.findIndex(arg => arg.slice(0,4).toLowerCase() === 'sort'); buildTurnOrder(selected, (sort > -1 ? args[sort] : '')); sendChat('Add Turn', `/w GM Turn Order Updated.` ); } }); });