1

I have followed a raycasting tutorial:

.

I stopped at 7: 17 because I don't need headshot detection. It says to exclude players to avoid putting the effect on yourself. However, I want to make something that hurts players. I don't want to use things that exclude everyone on a scoreboard in case more that one person tries to use it at once, on each other. What can I do?

2 Answers 2

3

To exclude players of your choice, you should be able to do something to the effect of /execute at @a[name=!Aceplante] run say hi and of course replace my name for yours. You can actually exclude as many players as you like.

If you want this to be flexible for any player running it, you could do /execute at @a[distance=0.1..] run say hi. This would execute at all players at a distance of greater than 0 (it cannot be 0 becuase that would include you/whoever is executing the command). In survival, it is impossible for players to be 0 distance away from each other due to collision, and although they technically could in creative, it is basically impossible without intentionally doing so with the /tp command. The point being it should work without issue.

2
  • yes but i dont want to have to manually put in my name. it needs to be automatic
    – 2wen
    Commented Aug 23, 2022 at 15:03
  • Then, you could do @a[distance=0.1..] which would be all players more than 0.1 blocks away from you. It cant be 0 becuase that would include you. But that would work for any player executing the command.
    – Aceplante
    Commented Aug 23, 2022 at 15:52
3

To exclude players of your choice, you can tag the players you want to exclude and execute the player don't have the tag

tag @s add this

execute as @a[tag=!this] run say test

tag @s remove this

with this method you can exclude more than 1 player

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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