Unknown global error, that seems to happen for no reason

For some reason getting error in this piece of code:

local function CheckConnections(previousRoot, array)
	
	local connectionValueList = {}
	local positionList = {}
	local connections = {}
	
	local overlapParams = OverlapParams.new()
	overlapParams.FilterDescendantsInstances = {workspace.Structures:GetChildren(), workspace.Overgrowth:GetChildren()}
	overlapParams.FilterType = Enum.RaycastFilterType.Include
	
	local upCheckBoxResult
	local downCheckBoxResult
	local frontCheckBoxResult
	local backCheckBoxResult
	local leftCheckBoxResult
	local rightCheckBoxResult
	
	for i, position in pairs(array) do
		
		upCheckBoxResult = workspace:GetPartBoundsInBox(previousRoot.CFrame * CFrame.new(0, 1.5, 0), Vector3.new(0.8, 0.2, 0.8), overlapParams)
		downCheckBoxResult = workspace:GetPartBoundsInBox(previousRoot.CFrame * CFrame.new(0, -1.5, 0), Vector3.new(0.8, 0.2, 0.8), overlapParams)
		frontCheckBoxResult = workspace:GetPartBoundsInBox(previousRoot.CFrame * CFrame.new(0, 0, -1.5), Vector3.new(0.8, 0.8, 0.2), overlapParams)
		backCheckBoxResult = workspace:GetPartBoundsInBox(previousRoot.CFrame * CFrame.new(0, 0, 1.5), Vector3.new(0.8, 0.8, 0.2), overlapParams)
		leftCheckBoxResult = workspace:GetPartBoundsInBox(previousRoot.CFrame * CFrame.new(-1.5, 0, 0), Vector3.new(0.8, 0.8, 0.2), overlapParams)
		rightCheckBoxResult = workspace:GetPartBoundsInBox(previousRoot.CFrame * CFrame.new(1.5, 0, 0), Vector3.new(0.8, 0.8, 0.2), overlapParams)
		
		if #upCheckBoxResult == 0 then
			continue
		else
			
			local connectionsValue = 0
			
			for i, obstacle in pairs(upCheckBoxResult) do
				if obstacle.Parent == workspace.Overgrowth then
					connectionsValue = connectionsValue + 1
				elseif obstacle.Parent == workspace.Structures then
					connectionsValue = connectionsValue + 5
				end
			end
			
			table.insert(connectionValueList, connectionsValue)
			table.insert(positionList, previousRoot.Position + Vector3.new(0, 1, 0))
			table.insert(connections, upCheckBoxResult)
		end
		
		if #downCheckBoxResult == 0 then
			continue
		else
			local connectionsValue = 0
			for i, obstacle in pairs(downCheckBoxResult) do
				if obstacle.Parent == workspace.Overgrowth then
					connectionsValue = connectionsValue + 1
				elseif obstacle.Parent == workspace.Structures then
					connectionsValue = connectionsValue + 5
				end
			end
			table.insert(connectionValueList, connectionsValue)
			table.insert(positionList, previousRoot.Position + Vector3.new(0, -1, 0))
			table.insert(connections, downCheckBoxResult)
		end
		
		if #frontCheckBoxResult == 0 then
			continue
		else
			local connectionsValue = 0
			for i, obstacle in pairs(frontCheckBoxResult) do
				if obstacle.Parent == workspace.Overgrowth then
					connectionsValue = connectionsValue + 1
				elseif obstacle.Parent == workspace.Structures then
					connectionsValue = connectionsValue + 5
				end
			end
			table.insert(connectionValueList, connectionsValue)
			table.insert(positionList, previousRoot.Position + Vector3.new(0, 0, -1))
			table.insert(connections, frontCheckBoxResult)
		end
		
		if #backCheckBoxResult == 0 then
			continue
		else
			local connectionsValue = 0
			for i, obstacle in pairs(backCheckBoxResult) do
				if obstacle.Parent == workspace.Overgrowth then
					connectionsValue = connectionsValue + 1
				elseif obstacle.Parent == workspace.Structures then
					connectionsValue = connectionsValue + 5
				end
			end
			table.insert(connectionValueList, connectionsValue)
			table.insert(positionList, previousRoot.Position + Vector3.new(0, 0, 1))
			table.insert(connections, backCheckBoxResult)
		end
		
		if #leftCheckBoxResult == 0 then
			continue
		else
			local connectionsValue = 0
			for i, obstacle in pairs(leftCheckBoxResult) do
				if obstacle.Parent == workspace.Overgrowth then
					connectionsValue = connectionsValue + 1
				elseif obstacle.Parent == workspace.Structures then
					connectionsValue = connectionsValue + 5
				end
			end
			table.insert(connectionValueList, connectionsValue)
			table.insert(positionList, previousRoot.Position + Vector3.new(-1, 0, 0))
			table.insert(connections, leftCheckBoxResult)
		end
		
		if #rightCheckBoxResult == 0 then
			continue
		else
			local connectionsValue = 0
			for i, obstacle in pairs(rightCheckBoxResult) do
				if obstacle.Parent == workspace.Overgrowth then
					connectionsValue = connectionsValue + 1
				elseif obstacle.Parent == workspace.Structures then
					connectionsValue = connectionsValue + 5
				end
			end
			table.insert(connectionValueList, connectionsValue)
			table.insert(positionList, previousRoot.Position + Vector3.new(1, 0, 0))
			table.insert(connections, rightCheckBoxResult)
		end
	end
	
	return connectionValueList
	return connections
	return positionList
	
end

They seem to be in the same function on the same column, but for some reason only one of them is considered existent, and that is “ConnectionsValueList”