Getting the last value of a table

You heard the title, how would I get the last value of a table? Now I’m not talking about any normal array, that starts at 1, what if the indexes are offset? For example, how would I get the last value of this table.

local _table = {
    [6] = "Hey",
    [7] = "Hi",
    [8] = "Hello",
}

I heard it was possible using next, but I don’t remember how.

1 Like

I don’t know if there’s a best way of doing this, but my solution would be:

local _table = {
    [6] = "Hey",
    [7] = "Hi",
    [8] = "Hello",
}

local MaxN = table.maxn(_table)

_table[MaxN]
1 Like

Just do

Table[#Table]
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.