I'm trying to make boss to say something when it has 100hp or lower and I was wondering if it could be done by using bossbar. I've already created working bossbar which has the same value as the boss' health.
So is it possible to execute a command when the bossbar's value is 100 or less? Or is there another way?
Create two scoreboards for fake players with nicknames HP and BOSSBAR. Then, connect to fill clock (/setblock ~ ~-1 ~ redstone_block and /setblock ~ ~ ~ air) command block with this command : /execute if score HP dummy >= BOSSBAR dummy run <command> . Then, connect your bossbar to scoreboard ( /execute store result bossbar minecraft:1 value run scoreboard players get BOSSBAR dummy ) and when player hit your boss, change scoreboard.
You are welcome For counting hits, use this two commands ( but firstly you need to run this command: /scoreboard objectives add HIT minecraft.used:minecraft.diamond_sword. You can change this command )
/scoreboard players operation BOSSBAR dummy -= <your nickname> HIT