my idea was to make the goal appear only when the player had collected all the coins, what can I do?
Develop games in your browser. Powerful, performant & highly capable.
When a player collects a coin you add +1 to the variable coins. If coins are x (the number needed) you let the goal appear.