Minecraft – How to execute different redstone circuits according to a scoreboard variable

minecraft-commandsminecraft-java-editionminecraft-redstone

I have a scoreboard variable that counts a killstreak of a player. when a player uses his killstreak I want to preform different actions acording to his killstreak points(1-9) and the team(red-blue). If his points are 0, I want to tell him that he can't use his killstreak.

How can I make different things happen (give players potion effects,custom items or activate some redstone circuits) according to a players killstreak points and the team he is in?

Best Answer

This can be done by using a different, well-defined target selector for each case. By well-defined, I mean that every selector only works for one score/team combination, and also that it will only "look at" the player executing the killstreak.

The latter part is best covered by another score, which I'll call EXECUTE. I assume it will be 1 for the player executing right now and 0 for everyone else. How exactly this is determined/set depends on your activation mechanism.

I'll call the score to check SCORE and the team will be TEAM. You can then use the following target selector to target the executing player, if and only if his score is X and he is on TEAM:

@a[score_EXECUTE_min=1,score_SCORE=X,score_SCORE_min=X,team=TEAM]

E.g. to give the player a speed effect when he has a SCORE of 4 and executes his killstreak ability, you would use

/effect @a[score_EXECUTE_min=1,score_SCORE=4,score_SCORE_min=4,team=TEAM] 1 20

If the command you want to trigger does not use a target selector itself, such as /summon, you have to /execute on the triggering player using this target selector.