TransWikia.com

How to give a random entity a certain effect after delay

Arqade Asked by Imo on August 28, 2021

execute at @a if score @p delay matches 50 run execute at @e[sort=random,limit=1] run effect give @s glowing

This is the command I have so far, I also have a delay command constantly running. I set the delay to 0 and also tested the command to give myself items if the delay is 50, using the same command. The command is working and it detects that the delay is at 50, but when targeting @e by random and using @s to give it an effect, for some reason it doesn’t work.

One Answer

The @s selector refers to the entity executing the command. In your case, the command is being executed by the command block, so the @s selector doesn't do anything.

You need to tell the command block which entity is executing the command in order to use the @s selector. You can do that using as <entity>. Also, you can make your command shorter and simpler by using the @e[sort=random,limit=1] selector directly in the /effect command. Example:

/execute as @a if score @s delay matches 50 run effect give @e[sort=random,limit=1] glowing

This command is saying: "execute the command from every player, test if the player's score on the delay objective matches 50, and if it does, give one random entity the glowing effect".

I recommend taking a look at this wiki page if you want to learn more about selectors.

Correct answer by MegaCrafter10 on August 28, 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