When concatenating (string..string) a variable that may be nil, two things to work around it:
1. wrap the variable in tostring() : s = "this is a test "..tostring(variable)
This will force nil values to a string "nil". Tables will become "table: 0E701648". etc
2. use the or operator : s = "this is a test "..(variable or "nil")
When you use (variable or "nil"), it will result in the variable if it has a value, or if it's nil, then the operand after the 'or'.
Does MobHealth2 return a value if the target isn't a mob? That among other things I couldn't tell right away.
|