I am very new to JavaScript and this is my first time posting on the forums so I apologize if this dose not belong here, but I can not get this to work and could not find any other forum post similar. I am trying to make an API that will create a token macro for my selected token, but I can't seem to get it to work right. Whenever I run it I get this Type Error TypeError: Cannot read property 'get' of undefined I don't think I am getting the selected objects id correctly and I am not quite sure how to go about it. I know this is an easy fix I just don't know what I am doing wrong. on("chat:message",function(msg){ if(msg.type=="api" && msg.content.indexOf("!test")==0){ var selected = msg.selected; var selObj = getObj(selected[0]._id); createObj("ability", { characterid: selObj.get("_id"), name: "testing", action: "testing", istokenaction: true, }); } });