Is there a way to test for a player's health Minecraft Bedrock?

I've been trying to make a Dead by Daylight map in Minecraft Bedrock but I can’t figure out how to make it so that when a player gets hit they receive a speed boost.


Solution 1:

This can be broken up into 2 problems first we need to detcet if a player hit another player.

First, create two scoreboard objectives: didDamage and hurtTime

scoreboard objectives add didDamage stat.damageDealt 
scoreboard objectives add hurtTime dummy

Then, run the following commands:

scoreboard players add @e hurtTime 1 

scoreboard players set @e hurtTime 0 {HurtTime:0s} 
execute @e[score_hurtTime_min=1,score_hurtTime=1] ~ ~ ~ tellraw @a[score_didDamage=1] "Nice hit!" 
scoreboard player set @a didDamage 0

Next, do this

scoreboard players add @e[type=player] hurtTime 1 
scoreboard players set @e[type=player] hurtTime 0 {HurtTime:0s}

Now, we test for the speed boost

/testfor @p[scores={hurtTime=..1}]

/effect give @p speed 1 2

Hope I got this right. I am still kind of new to!!