Thanks Noppes! Sorry for the delayed response, thought it was going to email me when I got a response lol. Really appreciate the help! Here's the final script that seems to work to respawn the npc when the scoreboard value changes. The whole resetScore thing is to ensure all the npcs with this script are reset before the scoreboard value is reset. There's probably a cleaner way of doing it, but I'm just happy it's working now haha.
var score = 0;
var resetScore = 0;
function tick(event){
if(event.npc.world.getAllPlayers().length > 0){
score = event.npc.world.getScoreboard().getPlayerScore(event.npc.world.getAllPlayers()[0].getName(),'bonfire','');
if(score == 0){
resetScore = 0;
}
if(score == 1){
if(resetScore > 2){
var players = event.npc.world.getAllPlayers();
for(i=0;i<players.length;i++){
event.npc.world.getScoreboard().setPlayerScore(players[i].getName(),'bonfire',0,'');
}
resetScore = 0;
return;
}
if(resetScore < 1){
event.npc.getStats().setRespawnTime(1);
event.npc.reset();
}
resetScore += 1;
}
}
}
function init(event){
event.npc.getStats().setRespawnTime(9999999);
}