Without delving too deeply, the error is pointing at this line:
button.label(7, 2, "Available: "..currEssentia.." is: "..(essCount[currEssentia]-1)*2)
And the error is basically telling you that the essCount array has probably not been initialised yet. It is a nil (non-value) rather than...