Code:
local db_mt = { __index = function(db, key)
if key == "char" then
if db.charName then
if type(_G[db.charName]) ~= "table" then
_G[db.charName] = {}
end
-- if type(_G[db.charName].raw) ~= "table" then -- <<<< not .raw
if type(_G[db.charName].global) ~= "table" then -- <<<< correct .global
_G[db.charName].global = {}
end
rawset(db, 'char', _G[db.charName].global)
The check is not on _G[db.charName].raw but on _G[db.charName].global.