I dont see a def_dice_mod in the html you posted either, nor do i see anything in the roll button that calls it. Also your checkbox has a value of -10, but in the sheet worker you are looking for a value of 1. Also you sheet worker is looking for an attribute named form_switch, but your getAttrs doesnt mention it, nor is it listed in the html you posted. Also there are two more issues with the if statement, which I'll explain after the code below. Here's a way to do it. First the inputs: set yup a checkbox as you have to handle the switch. Note the name change. And add a hidden attribute that will hild the switched dice. <input type="checkbox" name="attr_def_dice_switch" value="1" /> <input type="hidden" name="attr_def_dice" value=" 1d20cs>19cf1cf19 " /> Change your button to refer to this <button type='roll' name='roll_weapon_defense' value='&{template:hm_std} {{name=@{character_name} defends!}} {{weapon=@{weapon}}} {{def_roll=[[@{def_dice} +@{weapon_defense_mod_total}]]}} {{dr=[[@{dr}]]}} {{sdr=[[@{shield_dr}]]}}'>DEF</button> Now correct the sheet worker on("change: def_dice_switch", function() { getAttrs(["def_dice_switch"], function(values) { var switch = parseInt(values.def_dice_switch) || 0; var dice = switch ? "1d10!pcs>19cf1cf19" : "1d20cs>19cf1cf19"; setAttrs({ def_dice: dice }); }); }); Attributes in character sheets are stored as strings, not numbers, so using "if (attribute = something)" will usually fail because 1 does not equal "1". You have to convert them to a number first. Thats what the praseInt line above does. Secondly in javascript, = always assigns a value. To compare values, you have to use == or ===. This line: var dice = switch ? "1d10!pcs>19cf1cf19" : "1d20cs>19cf1cf19"; Is the same as doing var dice = '';
if(switch === 1) {
dice = "1d10!pcs>19cf1cf19";
} else {
dice = "1d20cs>19cf1cf19";
}
Notice how i use the triple equality here. That is the proper way to compare values in JS, but the values have to be of the same tpe (equal, and both numbers). The one line version is a lot more compact though...