I am making a murder mini-game and I wanted to make it so that when you right click with a sword you get speed boost, but that did not work so I tried making it that when they spawn in a bat, the bat dies and it gives only the player who spawned in the bat speed boost.

If this could be made much easier, I would gladly use that way.

  • 3
    Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins! – Frank Jun 4 '18 at 22:29
  • 1
    I'm with Frank, but I'm going to help him anyway. – Venya Jun 5 '18 at 0:08
  • @Kiirby5568 - In general, it helps if you can show us your commands that aren't working, as that's a great starting point for us to help you figure out exactly what's happening. :-) – Robotnik Jun 5 '18 at 1:45

The best way to see if someone used an item (in your case a spawn egg) is with scoreboards. From the quality of your question I'm going to assume you don't know what your doing.

First you're going to have to make the scoreboard

/scoreboard objectives add <score_name> stat.useItem.minecraft.spawn_egg

note: <score_name> can be anything you want, it just can't have any spaces, and its best to avoid long and confusing names, but keep it long enough so it makes sense. Also this will trigger on any spawn egg, just a warning.

Then once you've set up your scoreboard you can use it to check for people who've used the spawn egg, with a selector like this: @a[score_<score_name>_min=1,score_<score_name>=1]

Which can be used in any command that requires an entity selector, such as

/effect @a[score_<score_name>_min=1,score_<score_name>=1] minecraft:speed <time> <amplifier>

notes: <time> is how long the effect will last in seconds. <amplifier> is how strong it will be, plus one, aka 0 is speed I, 1 is speed II etc.

For you, you'll probably want to put that command into a repeating command block. Just make sure to clear the score after, or the person who used the spawn egg will get the effect re-applied every tick. To clear the score from everyone, since it doesn't matter who's score gets reset, something like this can be used:

/scoreboard players set @a <score_name> 0

As with the other commands <score_name> just has to be the same as when you made the scoreboard objective.

Hopefully your minigame works out, and for some advice, look into conditional command blocks, structure blocks, and scoreboards. All of them are extremely powerful when used right. Just start with scoreboards, they're the best.

| improve this answer | |
  • thank you for telling me this, sorry I forgot to input the commands I tried to use. – Kirby5568 Jun 19 '18 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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