Quote from OneLifeLeftYT»I tried it with y=62, it just killed me at any level
The command works as it's intended to. "/kill @a[y=62]" will kill all players, with the origin (X/Y/Z coordinates) of the command being that of the command block (except in this case, the Y has been changed to 62). There is no selection limiter (radius, delta), so it just selects everybody in the world.
In this case, you cannot simply have a /kill command because the restricted origin gets in the way. You must use /execute in order to create new origins at the target player's locations, and then use /kill with a selection limiter, while modifying the origin. For example, the following will kill any player between Y0 and Y62:
/execute @a ~ ~ ~ /kill @p[y=0,dx=0,dy=62,dz=0]To clarify: the player is attempting to kill somebody at their location, so long as that person is between Y0 and Y64. This also means it doesn't have to be the executing player that gets killed, as somebody can pass underneath the executor.
2