title: attempt to index global 'GameDatabase' (a nil value) - (A Garrysmod script)
body: <p>Im a bit stuck on figuring out why this is not working. I have not done anything to the code so im a bit curious to why it would no longer work. Any help is appreciated. Here are the errors im getting:</p>
  
  <pre><code>    [ERROR] gamemodes/harborrp/gamemode/data.lua:59: attempt to index global 'GameDatabase' (a nil value)
    1. Query - gamemodes/harborrp/gamemode/data.lua:59
     2. unknown - gamemodes/harborrp/gamemode/sv_gamemode_functions.lua:790
      3. UniqueID - [C]:-1
       4. echoToAdmins - addons/ulx/lua/ulx/log.lua:164
        5. fn - addons/ulx/lua/ulx/log.lua:202
         6. unknown - addons/ulib/lua/ulib/shared/hook.lua:110
  
  
  
  
  [ERROR] gamemodes/harborrp/gamemode/data.lua:158: attempt to index global 'GameDatabase' (a nil value)
    1. QueryValue - gamemodes/harborrp/gamemode/data.lua:158
     2. LoadInventory - gamemodes/harborrp/gamemode/inventory/sv_inventory.lua:41
      3. fn - gamemodes/harborrp/gamemode/inventory/sv_inventory.lua:58
       4. unknown - addons/ulib/lua/ulib/shared/hook.lua:110
  
  
  
  
  [ERROR] gamemodes/harborrp/gamemode/data.lua:158: attempt to index global 'GameDatabase' (a nil value)
    1. QueryValue - gamemodes/harborrp/gamemode/data.lua:158
     2. unknown - gamemodes/harborrp/gamemode/sv_gamemode_functions.lua:1068
  </code></pre>
  
  <p>Here's are locations it's referring to:</p>
  
  <p>Line 58:</p>
  
  <pre><code>function DB.Query(query, callback, qtype)
  
  local cBackFunc = function(r)
      if r[1].error then
          local err = table.concat({"tMySQL query error: ", r[1].error, debug.Trace() or "", "Query: ", query, "\n"}, "")
          DB.Log(err)
          ErrorNoHalt(err)
          r[1].data = nil
          //return
      end
      // lua_run DB.Query("SELECT amount, steam, rpname FROM metrorp_wallets limit 3", PrintTable, 1)
      if callback then
          if qtype == 0 then
              ErrorNoHalt("Query "..query.." used Type 0 in DB.Query!\n")
              local tbl = {}
              for i=1, #r[1].data do
                  local ind = 1
                  tbl[i] = {}
                  for a,b in pairs(r[1].data[i]) do
                      tbl[i][ind] = b
                      ind = ind + 1
                  end
              end
              callback(tbl, !r[1].error)
          else
              callback(r[1].data, !r[1].error)
          end
      end
  
  end
  GameDatabase:Query(query, cBackFunc)
  </code></pre>
  
  <p>end</p>
  
  <p>Line 158:</p>
  
  <pre><code>function DB.QueryValue(query, callback)
  local function cBack(r)
      if !r or !r[1].data or !r[1].data[1] then
          callback(nil, !r[1].error)
          return
      end
      local ind = next(r[1].data[1])
      callback(r[1].data[1][ind], !r[1].error)
  end
  GameDatabase:Query(query, callback and cBack)
  </code></pre>
  
  <p>end</p>