You need some criteria on the graphic that you can filter on. You could use the graphic's URL (or a subset of it) to match those specific graphics, but that's tedious to maintain and debug. Better would be to make a deck and have those tokens as a deck of cards, then play the sound only if cards from that deck are played to the tabletop. You can then add/remove/replace those tokens with impunity and not need to modify the script. Also, you can just draw all the cards from the deck and have a convenient place to pull all those tokens onto the table from. Cleanup becomes pretty easy also, you just recall all the cards. To do that, inside your on('ready',...) call, you'd find the deck, then load all the cards from the deck and store all their ids. Then you can just reference them when a graphic is added. Something roughly like this (typed from memory and not tested at all) code: on('ready', () => { let DamageCardIds;
let deck = findObjs({type:'deck',name:'Damage Cards'})[0];
if(deck){
DamageCardIds = findObjs({type:'card',deckid: deck.id}).map(c=>c.id);
}
on("add:graphic", function(obj) {
if(DamageCardIds.includes(obj.get('cardid')){
// you don't really need to call another script here, you could just start the track directly. sendChat('', '!sfx volume:100 action:play song:TrackName') ;
} }); });