I had explained the basic functions of BUTTON in detail in one of your previous posts. You can find it here:
https://miiverse.nintendo.net/posts/AYMHAAACAAADV0Z92l1DUw
You can wait for specific input using this syntax...
REPEAT
B2=BUTTON(2)
UNTIL B2 AND (#A OR #Y)
This will wait until the player presses either A or Y.