Here is my code: //Syntax for this API is !UseClassResource <Selected|token_id> <Selected|character_id> <Numer of Resource Spent> on("ready",function() { on("chat:message",function(msg){ if(msg.type=="api" && msg.content.indexOf("!UseClassResource")==0 ){ var selected = msg.selected; if (selected===undefined){ sendChat("API","Please select a character."); return; } var args = msg.content.split(" "); var command = args.shift().substring(1); if (command == 'UseClassResource'){ if (args.length < 3) { sendChat('SYSTEM', 'You must provide a selected token id, character id and the spell slot level used'); return; } // 1st Parameter should be the Token's Id var Selected_Tok_Id = args[0]; var Selected_Char_Id = args[1]; var Selected_ResourceNumberSpent = args[2]; Selected_ResourceNumberSpent = parseInt(Selected_ResourceNumberSpent,10); var Selected_Token = getObj('graphic', Selected_Tok_Id); var Selected_Character = getObj('character',Selected_Char_Id); if (!Selected_Token) { sendChat('SYSTEM', 'Selected token id not provided.'); return; } if (!Selected_Character) { sendChat('SYSTEM', 'Selected character id not provided.'); return; } if (!Selected_ResourceNumberSpent) { sendChat('SYSTEM', 'Resource Number Spent not provided.'); return; } //Preparing to get speakingas for sendChat var SpeakingAs = getObj('character', Selected_Token.get('represents')); if(!SpeakingAs){ SpeakingAs = Selected_Token.get('name'); } else { SpeakingAs = 'character|' + SpeakingAs.id; } var ClassRes = findObjs ({ _type: "attribute", _characterid: Selected_Char_Id, _name: "repeating_classresources_$0_ClassResourceTotal" }); var ClassResource = getObj('attribute',Selected_Character.get('repeating_classresources_$0_ClassResourceTotal')); sendChat(SpeakingAs,"Getting getAttrByName of repeating_classresources_$0_ClassResourceTotal|max is "+getAttrByName(Selected_Char_Id, "repeating_classresources_$0_ClassResourceTotal", "max")); var CurrentSum = getAttrByName(Selected_Char_Id, "repeating_classresources_$0_ClassResourceTotal", "current"); sendChat(SpeakingAs,"The typeof ClassResource is "+ typeof ClassResource); sendChat(SpeakingAs,"Current Sum as a string retrieved by getAttrByName is "+CurrentSum); CurrentSum = parseInt(CurrentSum,10); sendChat(SpeakingAs,"Current Sum changed to a Number is "+CurrentSum.toString()); sendChat(SpeakingAs,"The typeof of ClassRes is "+ typeof ClassRes); sendChat(SpeakingAs,"Trying to get ClassRes.get('current') is "+ClassRes.get("current")); //CurrentSum.set("current",CurrentSum); /* var MaxSum = getAttrByName(Selected_Char_Id, "repeating_classresources_$0_ClassResourceTotal_max", "value"); */ // sendChat(SpeakingAs,"CurrentSum = " + CurrentSum); //CurrentSum = parseInt(CurrentSum,10); //MaxSum = parseInt(MaxSum,10); // sendChat(SpeakingAs,"CurrentSum = " + CurrentSum); // Increment Spell Used //CurrentSum = CurrentSum - Selected_ResourceNumberSpent; /* if (CurrentSum < 0){ CurrentSum = CurrentSum + Selected_ResourceNumberSpent; sendChat(SpeakingAs,"It appears I tried use Ki points that was not available to me!"); } else { if(!ClassResource){ sendChat(SpeakingAs, "It appears the Class Resource I tried to use is Undefined, please examine your characters attributes and try again"); return; } else{ // ClassResource.set("current",CurrentSum); // sendChat(SpeakingAs, ClassResource ); // sendChat(SpeakingAs, ClassResource ); } } */ /*sendChat(SpeakingAs,"CurrentSum = " + CurrentSum); sendChat(SpeakingAs,"MaxSum = " + MaxSum); */ } // If command == UseClassResource } // If statement from the UsaClassResource and Api is msg.type }); });