Command blocks are confusing me
hey. is there a way to make an (for example) repetition command block by distance affect two players at the same time?
I have two command blocks.
one has something like execute @p[distance=..20] if scoreboard blackmusic matches 1700 run playsound blackmarket:music @s ~ ~ ~ 0.5
the other one is similar but it adds to the timer
the problem is when i have two players in the same place it wont affect both
another problem i have is making tp command blocks it affects the nearest player not the one who pressed it.
11 Replies
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close
!close
!solved
!answered
Requested by qwpm#0
@p
targets the nearest player by design
I think you can't target the player that triggered the command block@a
just do @a
That targets all players
yeah
all players
distance less than 20
for the first command
for the second issue if you really cant handle it ever being inaccurate, then you could make it a /trigger command if it HAS to be with command blocks but most of the time solving that issue is more effort than its worth
you're right
is there a way to do them knowing exactly who pressed them? maybe with plugins or mods?
in theory yeah ig but why not just use a command at that point it would just be simpler overall
cuz its having problems playing a sound with distance to more than two players
and the command block that stops the sounds stops the sound to the player that is like 4 blocks behind me for example
@Cooleg do you think i should be able to do it correctly with functions maybe?
in a datapack
if the player runs the function themselves
i think so
im not a command block wizard
i know its possible with /trigger commands
You can absolutely do it in a data pack more effectively. Tbh, anything you are doing for commands should be done in a data pack over command blocks.
The sound playing over a distance is because you want to be using the "at" functionality of
execute
.
You'd want to do something like execute as @a[distance=..20] at @s if score @s blackmusic matches 1700 run playsound blackmarket:music @s ~ ~ ~ 0.5
(I haven't tested this, or verified the syntax is correct)