The the problem is in this line:
tempZone.User.args[worldcheck(dbd.useryell[i].w)].args[dbd.useryell[i].zone] = {
Which table index is nil? It's hard to know since there are roughly 10 different indexing operations in that 1 line. I would recommend cleaning that up so that it's more readable, easier to find issues, and also more efficient:
Lua Code:
if(dbd.useryell[i]) then
if (not dbd.useryell[i].w) then dbd.useryell[i].w = "1" end
local wc = worldcheck(dbd.useryell[i].w)
local zone = dbd.useryell[i].zone
local world_args = tempZone.User.args[wc]
if(not world_args.args[zone]) then
world_args.args[zone] = {
type = 'group',
name = zone,
desc = zone,
args = {},
}
end
Without knowing the data, it's hard to pinpoint the problem but splitting that stuff up should help zero in on where the issue is. For example, if dbd.useryell[i].w is a value other than nil, "1", "2" then worldcheck() will return nil.
Efficiency-wise there is no need to call worldcheck over and over, so we assign the result to a variable and that can be re-used everywhere else in that loop.
Some of the variable names I used may not be ideal, so adjust as needed.