TransWikia.com

How do I summon something at all entities with a certain scoreboard value?

Arqade Asked on June 25, 2021

My friends and I are making a PVP map and we’re working on the summoner/mage class, which summons things that deal damage at the position of a projectile. For testing purposes, I’m making a snowball that summons lightning at its position. I have an objective called age that counts up every frame for every snowball, and the lightning will only be summoned after the snowball’s age increases to a certain value, to stop the lightning from spawning on the player and damaging them (for testing purposes, that "certain value" is 20). I have an objective called numbers which simply stores values (this is where the aforementioned 20 is stored). Right now, I have execute as @e[type=minecraft:snowball] if score @s[type=minecraft:snowball] age > 20 numbers run summon minecraft:lightning_bolt
but instead of summoning the lightning at the snowball, it summons it at the command block. How can I fix this?

2 Answers

as only changes the executor of the command (what @s is), not the position. To set the position of the command to the snowball, use at @s:

execute as @e[type=minecraft:snowball] at @s if score @s age > 20 numbers run summon minecraft:lightning_bolt

Also, you don't need [type=minecraft:snowball] in if score @s[type=minecraft:snowball] because @s will always be a snowball (you selected only snowballs in @e[type=minecraft:snowball]).

Correct answer by cherryblossom on June 25, 2021

CherryBlossom's answer is correct. I just wanted to point out another way to do it.

You can also type in the score directly in the target selector. This will save you some characters.

execute as @e[type=snowball,scores={age=20..}] at @s run summon lightning_bolt

the dots after the number 20 indicate "20 or larger".

Answered by BlackwoodHD English on June 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP