attempt to index field '?' (a nil value)


function ( Res )
			local ID = tonumber(Res[1][1]);
			GAMEMODE.GroupInfo[ID] = GAMEMODE.GroupInfo[ID] or {};
			GAMEMODE.GroupInfo[ID].Name = 'Unnamed Group';
			GAMEMODE.GroupInfo[ID].MOTD = 'No MOTD at this time.';
			GAMEMODE.GroupInfo[ID].Owner_SteamID = Player:SteamID();
			GAMEMODE.GroupInfo[ID].Members = {};
			
				GAMEMODE.JoinGroup(Player, ID);
		end
	);
end

Lines 10-21 error is on line 11.

Res is nil or Res[1] is nil.

How would I fix it?
p.s it happened on a GMod update

Start by posting more code, like where that function is called


GM.GroupInfo = {};

function GM.NewGroup ( Player )
    if Player:GetCash() < GAMEMODE.OrgStartCost then Player:BanForCheating(); return false; end
    Player:RemoveCash(GAMEMODE.OrgStartCost);
    
    tmysql.query("INSERT INTO `rp_org` (`name`, `owner_steamid`, `motd`) VALUES ('Unnamed Group', '" .. Player:SteamID() .. "', 'No MOTD at this time.')");
    
    tmysql.query("SELECT `id` FROM `rp_org` WHERE `owner_steamid`='" .. Player:SteamID() .. "'",
       **function ( Res )**
            local ID = tonumber(Res[1][1]);
            GAMEMODE.GroupInfo[ID] = GAMEMODE.GroupInfo[ID] or {};
            GAMEMODE.GroupInfo[ID].Name = 'Unnamed Group';
            GAMEMODE.GroupInfo[ID].MOTD = 'No MOTD at this time.';
            GAMEMODE.GroupInfo[ID].Owner_SteamID = Player:SteamID();
            GAMEMODE.GroupInfo[ID].Members = {};
            
                GAMEMODE.JoinGroup(Player, ID);
        end
    );
end
concommand.Add('perp_ng', GM.NewGroup);

I cant find where the function is called. Maby the Bold?

You do have the PERP sql tables set up and configured correctly right.
PERP does need dedicated mysql database. If you don’t have that would explain alot.

It just magically stopped working during a GMOD update

I’m still having problems, Help please.

Your sql query result is nil, check the connection to your database.

Thanks

Still error, Tried 3 Fresh databases, all from different places, tried another server running same copy on a different database, same error

Bump…

Bump