Ad
Log in to vote
0

Strange error? "bad argument #1 to 'pairs' (table expected, got number)"

Asked by
Abandion 118
1 year ago
elements = {
    ElemA = 1,
    ElemB = 2,
    ElemC = 3,
    Wood = 4,
    Metal = 5,
}
function elements:bynum(self, num)
    for i, v in pairs(self) do
        if num == v then return i end
    end
end

bad argument #1 to 'pairs' (table expected, got number) stack traceback:

1 answer

Log in to vote
2
Answered by 1 year ago

You do not need the "self" in the functions parameters

Ad

Answer this question