I wrote a script to change a token's HP (bar3_value) either by healing or doing damage and it doesn't seem to be working on PCs. It works PERFECT on NPCs I've had no issues at all there but when I use it on a PCs token nothing happens. Here is the script: //By Kastion
//<a href="https://app.roll20.net/users/3173313/kastion" rel="nofollow">https://app.roll20.net/users/3173313/kastion</a>
//version: 1.0
//use !change-hp <damage|healing> @{selected|character_id} to update character HP.
on('ready', function() {
on('chat:message', function(msg) {
if (msg.type == "api" && msg.content.indexOf("!change-hp") !== -1) {
let args = msg.content.split(/\s+/);
var c = getObj('character', args[3].trim());
var t = findObjs({
_type: 'graphic',
represents: args[3].trim()
})[0];
if(t && !isNaN(args[2])) {
var bar_value = parseInt(t.get("bar3_value"));
var hp_dif = parseInt(args[2])
var old_hp = bar_value;
if (args[1] == "damage")
var new_hp = bar_value - hp_dif;
else if (args[1] == "healing")
var new_hp = bar_value + hp_dif;
else {
log("Type of HP change not specified!");
return;
}
t.set({ bar3_value: new_hp });
if (new_hp < old_hp)
sendChat('', "/desc " + c.get("name") + " takes " + hp_dif + " points of damage.");
else
sendChat('', "/desc " + c.get("name") + " heals " + hp_dif + " points of damage.");
}
};
});
});
And the script is called using this macro: !change-hp ?{Change:|damage|healing} ?{Total:|0} @{selected|character_id} I have no idea why this would work on NPCs but none of the player characters. Can someone help me out here?