Cribbage - Total score please
Assuming you're talking about the "Pegging" phase of each hand of cribbage, and assuming that the cards you types in order were played in that order, here is the order of events.

Pegging Phase Answer

You lead with a 2. Currently, the count is at 2 and no point are scored.

Your son plays a 5. The count moves to 7 (2+5=7). No points are scored.

You play a 3. The count is at 10. No points are scored.

Your son plays a 2. The count is at 12. No points are scored.

You play a 4. The count is at 16. The last four cards played were a 4, a 2, 3 and a 5. That is a consecutive run of 4. You get four points.

Your son plays a 3. The count is at 19. The last three cards played were a 3, a 4 and a 2. That is a consecutive run of 3 cards. Your son gets three points.

You play a 5. The count is at 21. The last four cards played were a 5, a 3, a 4 and a 2. That is a consecutive run of 4 cards. You get four more points.

Your son finally plays an A. The count moved to 22. The last five cards player were a A, a 5, a 3, a 4, and a 2. That is a run of 5 cards. Your son scores 5 points for the run, and an additional 1 point for last card played.

Note these special scoring rules:

A player scores two points in the pegging phase when they play a pair. So if Player A plays a 4, and player B plays a 4 to bring the count to 8, Player B receives 2 points for playing a pair. Like all scoring in the Pegging Phase, the played cards must happen sequentially to count.

A player scores 6 points for playing triplets, and 12 points for four-of-a-kind. Again, these must happen sequentially. So Player A plays a 4, B plays a 4 to bring the count to 8 and scores 2 points, A plays another 4 to bring the count to 12 and scores 6 points, and B plays the last four to bring the count to 16 and scores 12 points.

Similarly, a sequential run scores points equal to the number of cards in the run.

Someone scores two points in the pegging phase when they play a card that makes the count equal 15 or 31. The count can never exceed 31.

There are special rules concerning what happens if a player cannot play a card without making the count exceed 31. For now, just know that the player who last played a card without going over 31 receives 1 point, called a "go" and then continues to play until they also can no longer play cards without exceeding 31.

Scoring Phase Answer

If you're talking about the scoring phase, wherein both players count up the number of points in their hand, your son still has not scored 40 points. We would need to know the cut card to determine how many points he did score, but at the moment, 5,2,3,A scores three points- for the run of A,2,3. If all four cards were also all of the same suit, they would score 4 additional points, bringing the hand's total up to 7 points.