Help: Runtime Lua Error

So, here’s the error:

Message: Interface\AddOns\DPS_Tracker\libs\EventHandler.lua:329: attempt to perform arithmetic on field ‘?’ (a nil value)

And here’s the code fragment that provokes the error:

if resisted ~= nil then
damageStats[RESISTED] = damageStats[RESISTED] + resisted ← line 329
end

This block accumulates the amount of resistence of a mob over the course of a combat encounter. More specifically, the ‘resisted’ variable is the 18th parameter of a CLEU spell or range _DAMAGE event.

Any help/advice would be appreciated.

If damageStats[RESISTED] hasn’t been initialised to a value (say zero), it will start out as nil.
nil + resisted == error.

if resisted ~= nil then
	if not damageStats[RESISTED] then
		damageStats[RESISTED] = 0
	end
	damageStats[RESISTED] = damageStats[RESISTED] + resisted <-- line 329
end

That was it. When I reset the table after each event, I was only reinitializing 9 of the 10 elements (I miss counted the zeros). Sheesh!

Thanks