Solution 1:
By setting up a score for every level/part of your map you could individually track how many times a player has completed every level/part, as well as only increseíng the levelscomplete score by once at first completion.
Setup:
I started by adding a score to the first level:
/scoreboard objectives add Level1 dummy
and the levelscomplete score:
/scoreboard objectives add levelscomplete dummy
Then also adding a fake player to hold a value:
/scoreboard players add Level_1 Level1 1
I added the player Level_1
, and gave them a score of 1 to Level1
. The name has an underscore so that no player can have that name.
Commands:
You can then test if the player has a score less than the fake player with this command:
execute as @a unless score @s Level1 >= Level_1 Level1 run scoreboard players add @s levelcomplete 1
By not executing the command if the player has a score more or equal to the fake player, we can make sure that the levelscomplete
score only increases by 1 once.
Then we put the second command in a chain command block after the first command block with this command:
scoreboard players add @a Level1 1
This will increase the player's score by 1 every time the player completes the level, but because the player has a score higher or equal to the fake player the levelscomplete
score doesn't increase further.
You would then need to set up one score dedicated for every level as well as a fake player. And you could then quickly change the two commands to work after each level completion. All the fake players would have a score of 1, no matter what level they are pared to.
Solution 2:
If your map is linear so a player can only complete level 3 if they have first completed levels 2 and 1. Then you could use this command:
execute unless score @p levelcomplete matches 1.. run scoreboard players add @p levelcomplete 1
This would only increase the levelscomplete
score if the player has a score less than the specified value.
If a player can complete for example level 3 before level 1, they could increase their score by 1 on level 3, and then not increase their score on level 1, because they already have 1 score.
But on a linear map, it could work, you just need to change the matches 1..
part to whatever level it is.