-2

How can I use the command

execute as @a[scores={health=<number>}] at @s run tp <coordinates>

with multiple lives? For example, in the command

execute as @a[scores={health=1}] at @s run tp 0 10 0

do not teleport only when it has 1 hp but teleport when it has less than 10 or 4 to 10 hp.

1 Answer 1

0

Assuming you already have the scoreboard objective for health set up, you can check for values in a range using min..max, for example, if you want to execute at all players with less than 10 (9 or less), you would use @a[scores={health=..9}] as the selector.

To disable someone from jumping, you can give them jump boost 128 with /effect give Player jump_boost 10 127

4
  • Note that if a min or max is omitted, it is assumed to be it's corresponding infinity, negative infinity for min and positive infinity for max. So ..9 means anything (negative infinity) up to 9.
    – Penguin
    Jan 11, 2021 at 16:27
  • @Penguin That's true but if the health objective corresponds to player health you can safely assume it won't go below zero.
    – 0mlml
    Jan 11, 2021 at 16:35
  • ik i was just adding what omitting the number meant, because u never specified
    – Penguin
    Jan 12, 2021 at 2:11
  • and it is working with pozition too? Jan 19, 2021 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .