How to prevent other buttons acting when a button is acting Javascript

I created a game like gold miner game. So when i click the gift, the tool will go to the gift and pick it. Ans i set up 5 gifts around. But when i click the first gift and other gifts in the same time, the tool will come to the last gift that i has just clicked. So how to prevent the tool execute other buttons actions when it’s still execute the first button.

I don’t know how to resolve it