3

My friends and I are making a arena minigame where you fight to the death. I want to make it so that after thirty seconds (600 ticks), you get an ender pearl, and once you use the ender pearl, the timer goes back down to zero and you get another one after another thirty seconds. However, I have gotten stuck at the part where the player gets the ender pearl. Here's what I'm doing so far:

scoreboard objectives add Natan dummy
scoreboard objectives add NatanSuper dummy
scoreboard players add @a NatanSuper 1
execute if score 321nathango Natan >= 1 and if score 321nathango NatanSuper >= 600 NatanSuper run give 321nathango ender_pearl{display:{Name:'{"text":"Natan Super - Ender Pearl","color":"gold","bold":true,"italic":true}'},Enchantments:[{}]} 1

Note: Natan is intended to be an objective name, not a scoreholder. This is because Natan is a pickable role from a list of different characters, each having their own abilities and timers, hence having different objectives.

I am trying to make it so that it only gives it to you after the 600 ticks pass AND you have the 'Natan' scoreboard greater than or equal to 1. By the way, 321nathango is my username that I am using for testing. It appears that even manually setting my scores to 1 and 600, nothing is happening.

Does anyone know what might be wrong?

1
  • I have seen the same issue you are having quite a few times before on Arqade. I'd point you to another question showing the same problem with a good answer, but I'm having trouble finding the best question to point you towards. I'll answer your question below, and if anyone wants to give a good duplicate target for this, feel free. Jan 29 at 6:02

1 Answer 1

5

The problem is in your last command, specifically this part:

execute if score 321nathango Natan >= 1 and if score 321nathango NatanSuper >= 600 NatanSuper run

The issue here is that you picked >=. You notice that at this point, you have six options: <, <=, =, >, >=, and matches. What they don't tell you is that the first five choices are for comparing one score with another score, not for comparing a score with a constant number.

This means that you are checking if the player 321nathango's [Natan] score is greater than or equal to the player 1's [and] score. It's treating the words 1 and as a player name and objective name respectively, so it's trying to look up another score, specifically the objective named and (which doesn't exist), and the player named 1.

If you want to compare a score with a constant number, use matches instead: this will allow you to enter a number instead of another player name and objective.

execute if score 321nathango Natan matches 1

And if you're curious how to do other comparisons other than a direct number match, that's done thru range notation:

  • 5: exactly 5
  • 5..: 5 or more
  • ..5: 5 or less
  • 5..10: 5 to 10
8
  • This seems like a poor alternative than just overloading the >= et al operators
    – corsiKa
    Jan 29 at 20:45
  • Thank you SO MUCH! It works! Jan 30 at 3:01
  • @ExpertCoder14 I mean, from the people that wrote the scoreboard interpreter and not being able to evaluate a score to a constant without matches. That is to say, your suggestion seems correct (and probably the most correct way) but it's unfortunate that the best way we have is not the best way possible and it's a shame the intuitive if score 321nathango Natan >= 1 doesn't just work.
    – corsiKa
    Jan 30 at 4:56
  • @corsiKa Commands are not a programming language. From the perspective of a commands developer, it makes sense to separate comparing scores vs comparing constants. It makes it important that we know exactly what we want to do. Personally this isn't a problem to me. Jan 30 at 18:25
  • @ExpertCoder14 Gonna have to disagree with you there - to me, anything fed into an execute command is absolutely a programming language. But, I'm happy to accept that we can't always change the world :)
    – corsiKa
    Jan 31 at 3:21

You must log in to answer this question.

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