Hello, I am very new to API and I'm trying to learn as I go. I found a script that lets my cleric summon a spiritual weapon token. However, I keep getting an error when the script attempts to give token control to the player. I am sorry if this has been posted before but I was unable to find an answer. Thank you for your time. Here is the coding: on("ready",function() { on("chat:message",function(msg){ if(msg.type=="api" && msg.content.indexOf("!spiritualWeapon")==0 && playerIsGM(msg.playerid)) { var selected = msg.selected; if (selected===undefined) { sendChat("API","Please select a character."); return; } var tok = getObj("graphic",selected[0]._id); var character = getObj("character",tok.get("represents")); var playerlist = character.get("controlledby"); (IF I DISABLE THIS PART OF THE SCRIPT IT WORKS BUT THE SUMMONED TOKEN HAS NO CONTROLER) createObj("graphic",{ left:tok.get("left")+70, top:tok.get("top"), height:70, width:70, pageid:tok.get("pageid"), layer:"objects", imgsrc:" This is where I have a link for the summoned token Image ", name:tok.get("name") + "'s Spiritual Weapon", controlledby:playerlist , (IF I DISABLE THIS PART OF THE SCRIPT IT WORKS BUT THE SUMMONED TOKEN HAS NO CONTROLER) aura1_radius:0, aura1_color:"#ffff00", showplayers_aura1:true }); sendChat(tok.get("name"),"I summoned a spiritual weapon."); spawnFx(tok.get("left")+70,tok.get("top"),"burst-holy",tok.get("pageid")); } }); }); This is the error message I receive: For reference, the error message generated was: TypeError: Cannot read property 'get' of undefined
TypeError: Cannot read property 'get' of undefined
at apiscript.js:10371:40
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)
at /home/node/d20-api-server/api.js:1663:12
at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560
at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)
at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)
at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489)
at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)
at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400