Dictionary Key exist check return error

Hello, i’m currently making a datatype documentation compiler and in order to make it work i need to check if a key already exist to not accidently overwrite the old one.

The issue is, when i try to check if the key exist using a path with has more than 1 key in it
EX : Result[Name][ConInput[v]][CName]
Where Result is the compiled dictionary. Name is the datatype name. ConInput[v] is the object(Property, Constructor, Function…) category and the CName is the name of the object.
It returns : attempt to index nil with ‘new’ *new is the object name

I tried searching this error but the one that i found with the key error was due to it been a datastore.

local Input = [[
BrickColor
Constructors
BrickColor.new ( number : Numerical Index )
Constructs a BrickColor from its numerical index.
Properties
number BrickColor.Number
The unique number that identifies the BrickColor.
]]

local SectionList = {["Constructors"] = true;["Properties"] = true;["Functions"] = true;["Math Operations"] = true}

function ConvertV2(Input)
	local ConInput = string.split(Input, "\n")
	local Name = ConInput[1]
	local Result = {[Name] = {}}
	local Sections = {}
	
	for i, v in pairs(ConInput) do
		if SectionList[v] then
			table.insert(Sections, #Sections + 1, i)
			table.insert(Result[Name], #Sections + 1, i)
		end
	end
	
	print(Sections)
	
	for i, v in pairs(Sections) do
		if ConInput[v] == "Constructors" then
			for ie, e in pairs(ConInput) do
				if ie > v and ie < Sections[i + 1] then
					local CName = string.split(e, " ")[1]
					CName = string.gsub(CName, Name..".", "")
					local CDesc = ConInput[ie + 1]
					local Arguments = string.match(e, "%b()")
					Arguments = string.gsub(Arguments, ".", {["("]="", [")"]=""})
					Arguments = string.split(Arguments, ",")
					print(Arguments)
					if not Result[Name][ConInput[v]][CName] then
						Result[Name][ConInput[v]][CName] = {{}, {}, {CDesc}}
					else
						table.insert(Result[Name][ConInput[v]][CName][3], #Result[Name][ConInput[v]][CName][3] + 1, CDesc)
					end
					
					for ai, a in pairs(Arguments) do
						local Split = string.split(a, ":")
						print(Split)
						for aai, aa in pairs(Split) do
							if aa == "" then
								table.remove(Split, aai)
							end
						end
						table.insert(Result[Name][ConInput[v]][CName][1], #Result[Name][ConInput[v]][CName][1] + 1, Split[1])
						table.insert(Result[Name][ConInput[v]][CName][2], #Result[Name][ConInput[v]][CName][2] + 1, Split[2])
						print(Split[1].." : "..Split[2])
					end
					print(Result)
				end
			end
		end
	end
end

ConvertV2(Input)
```The code is pretty messy but it is not even totaly working yet so im not at he stage of optimising everything

You can just check if the value retrieved from the table indexing is that of the expected type, so for example if a table value is expected all you need to do is.

if type(result) == "table" then
	--perform actions here after value type has been checked
end

Is result the path? If it is then i tried doing that but it didn’t work :
if type(Result[Name][ConInput[v]][CName]) == "table" then

The error was due to the second key not existing so the game did not undertand with im indexing a key on nil