diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 7f86a959d..543692d51 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -330,9 +330,16 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) + + -- hb.change_hudbar may be called with a non-existing hudbar like hunger. + if hudtable == nil then + return false + end + if not hudtable.hudstate[name] then return false end + local value_changed, max_changed = false, false if new_value then