2

Command block help

Weaseled 7/21/20 7:22 pm
1.2k
7/22/2020 7:56 pm
I know there must be a way to do this, but how can you make it so that if a player is at a specfic y level, they instantly die?
Posted by
Weaseled
Level 9 : Apprentice Waffle
13

  Have something to say?

JoinSign in

15

mememememe1
07/22/2020 9:30 am
Level 12 : Journeyman Explorer
How do I sense if a player said something in the chat?
1
Mayonnaise2124
07/21/2020 8:15 pm
Level 32 : Artisan Button Pusher
history
I think the below would work:

/execute if entity @a[y=<Whatever Y-level>..] run kill @a[y=<Whatever Y-level>..]
How it works:
/executeA command. More about it here.

if entityCheck if the specified entities exist. For more information, see here.

@a[y=<Whatever Y-level>..]Selects all players that are below y-level <Whatever Y-level>. The ".." means "and below". Replace <Whatever Y-level> with your Y-level

runRun the following command

kill @a[y=<Whatever Y-level>..]Kills those players, if they exist. Again, replace <Whatever Y-level> with your desired y-level.

And that's it! Hope this helps!
1
One_Nose
07/22/2020 8:57 am
He/Him • Level 59 : Grandmaster Dragonborn Hero
history
You actually don't need the execute commands. Most complex data packs are made of unnecessary execute commands. Also, the ".." should be before the <Y> if you want "or below". That would work:
kill @a[y=..<Y>]No need for execute.
1
Bertiecrafter
07/22/2020 9:48 am
Level 72 : Legendary System
history
The x, y, z arguments don't support ranges. There is dx, dy, dz for that.
In case @a[​y=<Y-Level>] doesn't work, try @a[​y=<Y-Level,dy=0] or @a[​y=<Y-Level>,dy=1]

You most likely want to add something like "gamemode=adventure" to that list to avoid killing yourself over and over again xD
3
One_Nose
07/22/2020 11:30 am
He/Him • Level 59 : Grandmaster Dragonborn Hero
Ahh I wasn't sure if it supports ranges so I checked and discovered it doesn't, then wrote it does because I'm a genius.
2
Bertiecrafter
07/22/2020 12:20 pm
Level 72 : Legendary System
Hahahahaha as Mark would say: "I'm a gunious!"
2
One_Nose
07/22/2020 12:54 pm
He/Him • Level 59 : Grandmaster Dragonborn Hero
I have no idea who is Mark but sure.
1
Weaseled
07/21/2020 8:33 pm
Level 9 : Apprentice Waffle
Yeah, thank you for your help on both of my problems!
I had almost gotten to that soloution, but I didn't have the killing only happening for the player at the y level on the last part, so I kept on dying lol. Thanks! :)
3
Weaseled
07/21/2020 8:02 pm
Level 9 : Apprentice Waffle
Or if they are on a specific block, such as on a diamond block.
1
garlicbreathinator
07/22/2020 1:51 am
Level 33 : Artisan Loremaster owo
Just in case, the way to do this is:
/execute as @a at @s if block ~ ~-0.01 ~ minecraft:diamond_block run kill @s

where "diamond_block" can be replaced with any block id


The code is pretty self explanatory, but basically it says "Have each player check the block right below them. If it is a diamond block, then run the kill command."



Note that because this checks the block RIGHT BELOW the player, they must actually be standing directly on it to die.
1
Weaseled
07/22/2020 7:40 pm
Level 9 : Apprentice Waffle
Okay, how should I configure the command block for this command, because it works if I run it from chat but I cant get it to work any other way.

Thanks!
1
garlicbreathinator
07/22/2020 7:47 pm
Level 33 : Artisan Loremaster owo
It should work with repeat and always on. Sometimes minecraft doesn't recognize repeating commands right and you need to fiddle around with it and try again.
1
Weaseled
07/22/2020 7:56 pm
Level 9 : Apprentice Waffle
Ok, thank you, I will try that.
1
Weaseled
07/22/2020 11:44 am
Level 9 : Apprentice Waffle
Okay, cool thanks ;)
1

Welcome