So you're setting whoTarg on line 18, it's just a string back then, "Orc-Warrior" (in this example, but it would change based on what you're inputting). You need to take that string and actually get the corresponding object to do stuff with it. Orc-Warrior is a "name", but you need the actual "monster" if that makes sense. You could do something like: var targetObj; var tokenPossibles = findObjs({_type: "graphic", name: whoTarg}); if(tokenPossibles.length > 0) { targetObj = tokenPossibles[0]; } else { log("Error: couldn't find a token with the name: " + whoTarg);
return; } //Then change all your .get() and .set() calls later on to use targetObj instead of whoTarg... However, another alternative, and perhaps a better one depending on your specific use case, would be to take advantage of the select information sent to the API in the msg object. If your players will select the object before doing the API call, you could do: var targetObj; if(msg.selected && msg.selected.length > 0) { targetObj = getObj(msg.selected[0]._type, msg.selected[0]._id); } if(!targetObj) { log("Error finding the object you selected."); //this really shouldn't happen
return; } //Again, change your later calls to use targetObj instead of whoTarg Anyway, those are two possibilities. Hope that helps! (Note that I didn't actually run either of those snippets through the API console, so there may be a typo, just let me know if it doesn't work for some reason).