You tried to escape the "%" using gsub "text2 = string.format("SCLog: Player %s says: %s. Their IP is: %s",getname(cn):gsub("%%", "%%%%"), text:gsub("%%", "%%%%") ,getip(cn))"
But you didn't use it in server commands (!mrank, !gtop, !grank...).
lol i would delete any logline code.