Executing the following command in chat succeeds (when a player is between y=0..58), but running it in a command block/function does not work.
"execute as @a[y=0,dy=58] run say found player"
Executing the following command in chat succeeds (when a player is between y=0..58), but running it in a command block/function does not work.
"execute as @a[y=0,dy=58] run say found player"
The command still works, but the location the command is run from is different. Since you didn't specify x and z coordinates but y coordinates, the player that is matched needs to be in the same x/z coordinates as the command block. (Edit: I agree that's a little unintuitive, but it's been like that since command blocks exist)
You can test that with the commands
(works) and
(doesn't work).
It was the same in 1.12.2, try
(works) and
(throws an error).
Also, if you put your command into a command block, the command will succeed if you're directly above or below the command block.
To fix your problem, use