1

I am trying to set a scoreboard to track the players' progress through my map with a scoreboard but I don't want it to continue counting up if the player plays the same part multiple times.

The command I tried is this:

execute if score @p levelcopmlete matches ..1 run scoreboard players add @p levelcopmlete 1 From what I Could see is the first part was not working, although it did work for a while before not working. I didn't change anything in between either.

I also tried:

execute if score @p levelcopmlete > 1 run scoreboard players add @p levelcopmlete 1

execute if score @p levelcopmlete >= 0 run scoreboard players add @p levelcopmlete 1

I started with the bottom one and when it stoped working I tried the other 2.

2 Answers 2

1

I figured out you can use this command: execute if score @p levelcopmlete matches ..0 run scoreboard players set @p levelcopmlete 1

1

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.

3
  • levelcomplete matches 1.. would add 1 to the players score if they had a score of 1 or above. You need ..1` for that. And that is what OP has in their original post.
    – Plagiatus
    Feb 9, 2023 at 8:32
  • No, in my case I use unless score if I would use the if statement then yes. You can see I have declared this in my answer. I tend to use unless because it is more predictable if you're trying to put limitations on something. Feb 12, 2023 at 11:24
  • ah yes, I must've glanced right over that somehow. You're absolutely right. For me that seems less intuitive, but whatever works works. In this case you have the number of the level in the check instead of the next higher up, so I can see how that might be better.
    – Plagiatus
    Feb 13, 2023 at 7:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .