How do you make your game have moves count down to end the game?

I’ve been looking everywhere to find out how to make my bejeweled game have 40 moves total, every move would count down until you hit zero and the game would end with your total score. does anyone know how to do something like this?

Yes, the script where you manage the game, needs a turns count, you need to take one of those turn in each move you do, and after your turns count reaches 0 then change your game status to game over or something like that.