Maybe you can change the structure, from:
[5976] = {name = "Ghoul", mana = 100},
[3113] = {name = "Ghoul", mana = 100},
To:
[1]= {id = 5976, name = "Ghoul", mana = 100},
[2] = {id = 3113, name = "Ghoul", mana = 100},
So you can iterate over it with a for:
for g, #BodyMonsterNames do
if...