-1

I am making a game where if the player is at half a heart I want to teleport them to a place. Is it possible to detect player health with command blocks? Thanks.

darthvader1925
  • 365
  • 1
  • 2
  • 15

1 Answers1

2

For this method you need a scoreboard for health. You can make it with the following command.

scoreboard objectives add health health

To test if a player has a certain amount of health, you can do it with the following command:

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

Default health is 0–20. Half a heart is 1.

One 2 Many
  • 12,607
  • 6
  • 48
  • 86
randomuser922
  • 1,028
  • 1
  • 6
  • 19