Can Someone tell me why this code doesn't work

BTW

You have defined global and local die1 and die2 variables.

Always comment the code lines in your sketch.


Show us a good schematic of your proposed circuit. Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.