ID:2067733
 
runtime error: Cannot read 0.hidestat
Why are mobs becoming 0 and how can I fix this?
Maybe you can show us your code so we know what's going on?

UpdateState(value, max_value)
if(usr.hidestat && !usr.stathid)
for(var/atom/X in usr.client.player_gui)
X.invisibility=0
usr.stathid=1
else if(usr.stathid && !usr.hidestat)
for(var/atom/X in usr.client.player_gui)
X.invisibility=0
usr.stathid=0
usr is not some automagical reference to whatever player mob.
It's use is only valid in input events, and almost nowhere else.

What is UpdateState() defined under?
obj
gui
hud
New(client/C)
if(!C) return
else if(ismob(C))
var/mob/M = C
C = M.client
if(istype(C, /client))
C.screen += src

statbar_background
//screen_loc = "WEST,NORTH:1"
screen_loc = "3:6,20:10"
icon = 'icons/gui/stats_background.png'

statbars
layer = 20

var
num_states

proc
UpdateState(value, max_value)
if(usr.hidestat && !usr.stathid)
for(var/atom/X in usr.client.player_gui)
X.invisibility=0
usr.stathid=1
else if(usr.stathid && !usr.hidestat)
for(var/atom/X in usr.client.player_gui)
X.invisibility=0
usr.stathid=0
icon_state = "[round(value / max_value * num_states, 1)]"
This is usr abuse plain and simple. You'll want to define an owner under the statbars or call UpdateState() with an arg of the owning mob.