attempt to index field 'Config'

I am porting a gamemode to gmod 13 from gmod 12, and im getting an error

[ERROR] gamemodes/rp/gamemode/cl_init.lua:901: attempt to index field 'Config' (a nil value)
  1. unknown - gamemodes/rp/gamemode/cl_init.lua:901

heres the cl_init.lua code, starts from the line 900 in the file

function GM:Think()
	if ( self.Config["Local Voice"] ) then
		for k, v in pairs( player.GetAll() ) do
			if ( hook.Call("PlayerCanVoice",GAMEMODE, v) ) then
				if ( v:IsMuted() ) then v:SetMuted(); end
				if ( !v:IsMuted() ) then v:SetMuted(); end
	-- Call the base class function.
	return self.BaseClass:Think();

when i start singleplayer with the gamemode, i get spammed with that error and all i see is this screen

how do i fix this error?

it means ‘Config’ isn’t defined anywhere.
Do GAMEMODE.Config rather then self.Config, whatever game mode you’re using should have

GM.Config = {}

in it’s configuration file. (Probably shared.lua or it may even be named configuration.lua or something)

You should also find

GM.Config["Local Voice"] = true


GM.Config["Local Voice"] = false

somewhere in the game mode, again most likely a shared file.

EDIT: Also are there any error messages that occur before this? The file where GM.Config is defined may be attempting to load after an error in the file that includes it or there could be a error in the file itself before GM.Config is defined.

It didn’t work
Also, i looked up in the console and i found another error

[ERROR] gamemodes/rp/gamemode/cl_init.lua:339: attempt to index field 'Config' (a nil value)
  1. HUDPaintESP - gamemodes/rp/gamemode/cl_init.lua:339
   2. unknown - gamemodes/rp/gamemode/cl_init.lua:780

Heres the lines of code starting from 331

function GM:HUDPaintESP()
	--Comments added due to request. Some things are fairly obvious, but it'd be nice if Garry did this with his stuff ¬_¬
	if ( lpl:Alive() and not lpl._Sleeping ) then  --I hope this is obvious
		local trace = lpl:GetEyeTrace() -- Send a trace down the center of the player's screen to see what they're looking at
		local ent -- Set up an empty variable
		if trace.Hit and not trace.HitWorld then -- if they're looking at something and it isn't the map
			ent = trace.Entity -- Set the variable we just made to the thing they're looking at
		local fadeDistance = self.Config["Talk Radius"] * 2; -- Set the distance that text will be completely faded to twice the talk radius
		for _,tent in ipairs(ents.GetAll() ) do -- Go through every entity on the map (props, players, items etc)
			if (tent:IsValid()) then -- WHAT THE FUCK GARRY, WHAT HTE FUCK
			-- We are now in a loop, and there is only one entity handled at a time.
			local class = tent:GetClass() -- Get the entity's class (like prop_physics)
			local pos = tent:GetPos(); -- Get the entities position in the world
			pos = self:AdjustPosForStupidEnts(tent,pos) -- Some entities like players and cars act weird. This function fixes it
			local screenpos = pos:ToScreen() -- Translate the world position into a screen X,Y position
			local dist = pos:Distance(lpl:GetPos()) -- Caclulate the distance we are away from the entity for quicker usage later
			if screenpos.visible and (dist <= fadeDistance or self:IsUsingCamera()) then -- Check if the screen X,Y position is on the screen (we don't want to draw it if it's not) and that the entity isn't too far away, or if the player is using the camera.
				local tr,lookingat = {} -- Set up a table in tr for the next trace, and set up an empty (and therefor false) variable called lookingat
				if ent == tent then -- If we're looking at the entity, we want the old behavior

also, im not sure if you need this, but heres another line of code starting from 779

function GM:HUDPaint()
	if ( !self:IsUsingCamera() ) then
		self:DrawInformation(self.Config["Website URL"], "ChatFont", ScrW(), ScrH(), color_white, 255, true, function(x, y, width, height)
			return x - width - 8, y - height - 8;

Add me on steam and mark this as solved - I’ll help you fix this, your problem isn’t with the way the code is written it’s you’re not defining
GM.Config anywhere

Edit: I know this because none of your references to GAMEMODE.Config work.

i added you but you’re not accepting

Sorry accepted - the problem isn’t with the code itself.
There is an error that occurs before sh_config.lua is included so it prevents it from being loaded, therefore GM.Config is technically not defined - fix those errors and it’ll work! (Get LibMySQL and tmysql module) that should be it.