2

Need help with command block

MM824 11/20/20 5:08 pm
155
11/21/2020 9:03 am
hello! i am trying to make a command block/s that senses if a player comes near it, and then it chooses to kill them, or let them walk bye, depending on if they are a certain player. So lets say i want it to let me by, but if anyone else walks bye, the would get killed. does anyone know how to do this? I used to to it with the /testfor command, but it doesn't exist anymore.
Posted by
MM824
Level 1 : New Miner
0

  Have something to say?

JoinSign in

4

garlicbreathinator
11/20/2020 6:32 pm
Level 33 : Artisan Loremaster owo
history
/testfor was removed in 1.13, where it was replaced with "/execute if/unless entity <entity selector>" which lets you essentially incorporate an unlimited number of tests into a single command. However, the best way to do this is just an entity selector.
/kill @e[​tag=!<tag>,distance=<target_range>] will kill all players in range <target_range> that do not have the tag <tag>.

Range values in 1.13+ are used in entity selector arguments and scoreboard values. They work like this:
Example of a rangeMeaning of range
4
Exactly 4 (blocks away)
2..
2 or more (blocks away)
..5
5 or less (blocks away)
4..10
inbetween 4 and 10 (blocks away)

You want distance:..10 to kill all players in 10 blocks, for example.

Tags are pieces of data attached to entities that you can sort them by. You can add or remove them with /tag (1.13+) or /scoreboard players tag (1.12 or earlier).

For example, if you do "/tag <player> add give_items" and then run "/give @e[​tag=give_items] minecraft:diamond 64" it will give whatever players were tagged the diamonds. You want to give yourself the tag BEFORE you set up the death loop, since it will kill you as it starts if you do not have it.

Again, the commands are

/tag @p add allowed_in

kill @a[​distance=..5,tag=!allowed_in]
1
MM824
11/21/2020 9:03 am
Level 1 : New Miner
Wow thanks sooo much!
1
ItzTappa
11/20/2020 5:30 pm
Level 34 : Artisan Vampire
/testfor (player you want to kill) [r= (how far you want it) just do a number like 1 block 2 blocks away. and make it a repeating command block and always active

once your done with that place a comparator in front of that command block, then a repeater in front of that. then hook it up to another command block that says /kill @p

and that's it,
if you are confused contact me,
1
MM824
11/21/2020 9:02 am
Level 1 : New Miner
Hey so the /testfor command was removed. But thanks for trying to help!
1

Welcome