3

I want to select all players that do not have a specific scoreboard objective value set. I have tried doing testfor @a[score_hasJoined=] and testfor @a[score_hasJoined_min=], but it still won't work. The hasJoined objective is a dummy objective, and therefore users do not start with 0 when they join.

I want to set all players' score without the score to 0. I have thought that there maybe is an objective that automatically starts at 0 but I couldn't find one.

3
  • I know this has come up before, but I can't find the question right now. I think it was a tangential issue for another problem.
    – MrLemon
    Commented Jun 27, 2015 at 15:21
  • Selecting someone without a score set is impossible, but we might be able to solve your actual problem. What exactly is it you are trying to achieve? Do you just want to select all players that have just joined the server for the first time? Or just joined in general? Or joined a minigame/team/...
    – MrLemon
    Commented Jun 27, 2015 at 15:24
  • 2
    Have you tried something like running scoreboard players add @a hasJoined 0 (I think that's the correct syntax) on a 20Hz clock? That should effect everyone, and won't actually change the value of the objective.
    – MBraedley
    Commented Jun 27, 2015 at 15:35

1 Answer 1

7

The problem is that you can't target someone without a score using a score selector. So the solution, not surprisingly, is to give everyone a score. You don't have to change anyone's score value either; instead, just "increment" everyone's score by 0, in your case, with the following command:

/scoreboard players add @a hasJoined 0

Better yet, throw that command in a command block that is triggered off a 20Hz clock, and you're guaranteed that everyone always has a score.

The way this works is that everyone that already has a score in the hasJoined objective won't have their score changed, but everyone else will have their hasJoined score set to 0.

4
  • Actually, I lied, you can target them, but I like this better.
    – MBraedley
    Commented Jun 27, 2015 at 18:43
  • How do you target them? Commented Jun 27, 2015 at 21:05
  • 1
    Actually, it looks like I was mistaken. I had the syntax mixed up, and a test succeeded when it should have failed.
    – MBraedley
    Commented Jun 27, 2015 at 21:45
  • Thank you, this is sooooo helpful! Very creative solution. I didn't realize you could add 0 to everyone's score.
    – retrovius
    Commented Aug 30, 2022 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.