Hi SpyDaniel, there are multiple ways to do this, some very complex (but also flexible, great for turnbased strategy or RPG gameplay with lots of stats defining units or characters). But the basic structure would be:
[construct 2 expressions are in brackets]
On event trigger (attack animation end or frame X of animation, or on a function triggered by the attack):
Pick the player object (not needed if there is just one)
add to variable - [choose(0,0,0,1)]
^ choose picks a random choice out of the defined possibilities, in this case 3 zeroes and 1 one value. So you have 25% odds of 1 getting added to the variable.
If you want more complex logic (but easier to maintain and also change while the game is running thus more dynamic), you could do for example an event block as below with the same initial triggers but two sub-event blocks:
Conditions - same as above.
Subevent 1 conditions - nothing (leave it empty, this is needed only so that the number can be checked by the conditions in the second subevent)
Subevent 1 local variable - number type [Roll = 0]
subevent 1 actions - set variable Roll to [random(0,100)]
end subevent 1 block
subevent 2 conditions - if Roll < 25
subevent 2 actions - add to variable 
End subevent 2 block
^The above is probably the best structure if you want to have flexibility. Basically Roll can be set in any way you wish, you can use a random number within a range, add another variable to it (static player bonus to mining or a multiplication bonus like [Roll*player.miningefficiency] object variable). You can set up a custom function for dice rolling to determine the roll value setting Roll etc.
Also in subevent 2 conditions you can test to see if roll is below another variable, for example if Roll<player.miningskill (mining skill being a variable that increases with better gear or experience). That would effectively translate to increasing player odds of adding to the mystical variable (like mining experience? Or maybe loot?).