I'm not sure a script is warranted. You can just add an ability to the player characters named Defense, set it as a token action, and have them click it when they need to defend, tell them the DC. Basically just like a saving throw. &{template:default}{{name=@{character_name}}}{{Defense=[[1d20+(@{ac}-10)]] | [[1d20+(@{ac}-10)]] }} Adjust as needed for your character sheet.