If you use a 'for loop' without checking whether the player is active or not. Your script can be enhanced very easily. Just take a look at my example to see where you made failures or what could be made better:
const
// For line breaks.
br=#13#10;
// HUD colour.
cl_interface=$FFFFFF;
// Frame for the HUD.
l_line='-----';
// Example use for the HUD.
l_health='Health: ';
procedure draw_hud(id:byte);
begin
drawtext(id,l_line+br+
l_health+getplayerstat(id,'health')+'/150'+br+
l_line
,120,cl_interface,0.075,15,300);
end;
procedure apponidle(t:integer);
var
i:byte,
begin
for i:=1 to 32 do
// Check if the slot is active before trying to do anything with it.
// Also check if the slot is used by a human player.
if (getplayerstat(i,'active')=true) and (getplayerstat(i,'human')=true) then
draw_hud(i);
end;