Run Playsound Command as an item?

em
7

Below you can see my attempt by the command, which is in a command block

execute as @e [type = item] run execute at @e [type = item] run playsound minecraft: entity.bat.takeoff master @a [distance = .5] ~ ~ ~ 40000 1

This should do the following: As soon as a player is within a 5-block radius of the item, a play sound should be performed. When I do this, however, you hear nothing. You only hear something when you are in the vicinity (5 blocks) of the command block executing the command. Where is the mistake in thinking?

te

Your text is not expressed enough! For such things I can give you Minecraft Command Generator: https://mcstacker.net/ This is for 1.15 here for 1.8 - 1.12.2: https://mcstacker.bimbimma.com/

ni

You wrote at the end of the command ~ ~ ~, so this command causes the sound to be there

Ar

You can write "execute as @e [type = item] at @s" instead of "execute as @e [type = item] run execute at @e [type = item]", it works the same way.
What gtulolich wrote is not true. The command is executed at the point of the item, so it also plays with the item.
I've just tested it again, the command works for me. However, it runs consistently and not just once, as you probably want it to.

em

I know MCStacker, but I don't find the required command section (execute as) there… Can you help me there? Or what do you mean?

em

1) You wrote @s in your first comment. @s is for players, then the player is chosen as position (but I want to select the item lying on the ground)

2) You sent me a suggestion for improvement (and I'm very grateful for that!), But what was my mistake above?

em

Mathis?

Ar

Sorry, I'm not traveling on Girlfriend that often (if you have Discord: CommandMC # 7964)

@s stands for what is currently executing the command. So if the player can be something else. In the case here it is @e [type = item]. So I'm just saying "Execute as every item and also with every item".

And as I said, I couldn't find a mistake with the command. It worked for me right away. You can test your test world on z. B. Upload MediaFire and I'll take a look