Looking again at your code it looks like you have too many brackets at the end. Thinking about what you need, a couple of things occur to me: What if the status marker is already set? Shouldnt you be looking at the value of the locked attribute, and adding the status marker if its true/1, and removing it if 0? You dont need to sendchat to tokenmod. You can simply set the statusmarker directly in your script, using the api commands to do that. Setting a statusmarker looks something like this: token. set (markerName, true);
token. set (markerName, false);
So, maybe this script (untested) will work. on("change:attribute:current", function(obj, prev) {
if(obj.get("name") === "locked") {
const markername = 'status_padlock';
let charid = obj.get('_characterid');
let value = obj.get("current");
let tokens = findObjs({ type: 'graphic', represents: charid});
for ( i = 0 ; i < tokens . length ; ++ i ) { tokens[i]. set (markerName, (value === "1" ? true: false) );
}
}
}); This line tokens[i]. set (markerName, (value ==="1" ? true: false) ); Might be wrong. Maybe it should be if (value === "1") {
tokens[i]. set (markerName, true);
} else {
tokens[i]. set (markerName, false);
} Also, I have assumed your locked attribute will only have two values, "1" and "0". I'm not too familiar with this type of code, but maybe this will help.