Combination Lock - Pressing buttons in order

How would I make a lock with buttons on screen and you would have to press the right ones in a right order, kind of like the O2 task in Among us.

There are various ways to achieve this, I believe.
Here’s one that seems fairly simple.
Let’s say you have four buttons. Give each one an “order” variable: 0,1,2,3.
Now make a scene variable “WhichToClick”.
When the player clicks on a button, check if its “order” = “WhichToClick”. If it is, add 1 to “WhichToClick”. If it’s wrong, set “WhichToClick” back to 0.
If “WhichToClick” = [number of buttons - 1], victory.