ok, I am sure this is going to be a SMH moment, but I cannot get the selected token resolved to the character to gather information for a new initiative script I am writing for the API compatible SW character sheet. I have scavenged some old code of mine I wrote for my C&C game, but I am missing something. I have a token selected and am getting an error "For reference, the error message generated was: TypeError: Cannot read property 'id' of undefined
TypeError: Cannot read property 'id' of undefined
at apiscript.js:18:49
"var StarWarsFFGScripts = { name: 'Star Wars FFG API Compatible Scripts', version: '0.0.1', author: 'Scott Westberg', lastUpdate: '02/08/2021' } log('-=> '+StarWarsFFGScripts.name+' v'+StarWarsFFGScripts.version+' <=- '+StarWarsFFGScripts.author+' '+StarWarsFFGScripts.lastUpdate) on('ready', function() { on("chat:message", function(msg) { if (msg.type === 'api' && msg.content == "!rollInitCool") { var selectedToken = msg.selected var tokenID = selectedToken._id var tokenObj = getObj("graphic", tokenID) var characterObj = getObj('character',(tokenObj||{get:()=>{}}).get('represents')); var initCool = getAttrByName(characterObj.id,'npc-minionskillVigilance','current') sendChat('Initiative',initCool) } }) })