Help with reseeting boss

scoreboard players remove $attack_dur boss 1

execute if entity @e[tag=skelly.king] if score $attack_dur boss matches ..0 run function levels:cave/boss/active/attack

execute store result bossbar time:skeleton_king value run data get entity @e[tag=skelly.king,limit=1] Health
execute unless entity @e[tag=skelly.king] if entity @e[tag=player] positioned 161 -60 -138 run return run function levels:cave/boss/active/summon
execute if entity @e[tag=player] unless entity @e[tag=skelly.king] run return run scoreboard players set $boss_num main 0

What i want to happen: When player (mob) dies, it resets the boss. but that's not happening.

Continue to help post