Q:

How do i create a new gsheet with a script already in it? 

I have a system whereby I automatically upload files to Gdrive and Gdrive searches those files, combines them and adds a template sheet to the combined sheets.  
In the template gsheet I need to be able to reference cells inside other tabs without using the tabs name (the tabs name will be changing all the time).  The only way I know how to do this is by using google apps script inside the gsheet.  The problem is the way I generate the template is by opening the template and copying all values to a new tab in the newly created combined gsheet and it wont copy the google apps script with it.  
Even if i can automatically add a script to a new sheet using code I still need that script to automatically run on that sheet because I have another master sheet that looks for all of the newly created files and adds summary information from all of them. 
Here is my Gdrive script if it helps. 

/* Head Master Info >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */

/* Top Level Google Drive Folder ID */
var TopDriveFolderID = "0B2rN5b8fW77ldXZXOXFLZGlSamc";
var BaseNumberOfFilesInFolder = 4;
var NewSSAnalyzerSheetId = "1VyL8XL1x41H6yetcrwfUhVcch-DUsngY4-bHCbo-_xM";

/* End Head Master Info >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

/* Body >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

/* Functions to iterate through all sub folders */
function listFolders() {
  var parentFolder = DriveApp.getFolderById(TopDriveFolderID);
  var childFolders = parentFolder.getFolders();
  while(childFolders.hasNext()) {
    var child = childFolders.next();
    //    Logger.log(child.getName() + " |Drive_ID: " + child.getId());
    var folderId = child.getId();
    // **the folderId Variable is also the folder ID,
    //    hence they are used interchangeably **
    
    /* SpreadSheet Combiner >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/    
    
    /* Name of combined Spreadsheet*/
    var newSpreadSheetName = DriveApp.getFolderById(folderId).getName();

    /* Retrieve the desired folder */
    var myFolder = DriveApp.getFolderById(folderId);
    
    /* Get all spreadsheets that resided on that folder */
    var spreadSheets = myFolder.getFilesByType("application/vnd.google-apps.spreadsheet");
    var spreadSheetName = myFolder.getName();
    //    Logger.log(spreadSheetName);
    
    /* Check if a file needs to be created or if one already exists*/  
    var theFolder = DriveApp.getFolderById(folderId);
    var files = theFolder.getFiles();
    var fname = theFolder.getName();
    
    var cnt = 0;
    var file;
    
    /* Check the quantity of files in a folder to see if you need to combine the sheets and create a file*/  
    while (files.hasNext()) {
      cnt++;
      file = files.next();
      //Logger.log(file.getName());
      if (cnt > BaseNumberOfFilesInFolder) {
        Logger.log("File already exists")
        break;
      } 
      ;
    };
    
    // If a file needs to be created this checks it and creates it
    Logger.log(cnt + " is the number of files '"+ newSpreadSheetName+ "' has."); 
    if (cnt > BaseNumberOfFilesInFolder){     
      Logger.log("No file needs to be created")
    }else{
      
      /* Create the new spreadsheet that you store other sheets */ 
      var newSpreadSheet = SpreadsheetApp.create(newSpreadSheetName);
      
      
      /* Iterate over the spreadsheets over the folder */
      while(spreadSheets.hasNext()) {
        
        var sheet = spreadSheets.next();
        
        /* Open the spreadsheet */
        var spreadSheet = SpreadsheetApp.openById(sheet.getId());
        
        
        /* Get all its sheets */
        for(var y in spreadSheet.getSheets()) {
          
          /* Copy the sheet to the new merged Spread Sheet */
          spreadSheet.getSheets()[y].copyTo(newSpreadSheet);
          
          
          /* In order to move the file to the folder we want and because 
          google considers the SpreadSheet a Google Spreadsheet
          instead of a file, we have to convert the SpreadSheet to a file in
          order to move it. Thats what the next 2 lines of code do.*/
          var getNewSSid = newSpreadSheet.getId();
          var SStoGFile = DriveApp.getFileById(getNewSSid);
          /* Actually moving the file*/
          DriveApp.getFolderById(folderId).addFile(SStoGFile);
          /* Deleting the duplicate file that was created in the process*/
          var rootFolder = DriveApp.getRootFolder();
          DriveApp.getRootFolder().removeFile(SStoGFile);
          
        }
      } 
      
      /*Code to add our base analysis template to the new combined template that was created;*/
      //Grabs the template
      var sss = SpreadsheetApp.openById(NewSSAnalyzerSheetId); //replace with source ID
      var ss = sss.getSheetByName('Analysis Tab'); //replace with source Sheet tab name
      var range = ss.getRange('A1:E6'); //assign the range you want to copy
      var data = range.getValues();
      
      //Copies the template info into the current newly created sheet
      var tssId = newSpreadSheet.getId();
      var tss = SpreadsheetApp.openById(tssId); //replace with destination ID
      var ts = tss.getSheetByName('Sheet1'); //replace with destination Sheet tab name
      ts.getRange(1,1,6,5).setValues(data); //you will need to define the size of the copied data see getRange()
      

      Logger.log("New File was created with the name - " + newSpreadSheetName)
    }
  };
  
  
  /* End SpreadSheet Combiner >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/       
  
  
  getSubFolders(child); 
  
}


 /* Necessary Function to help the above loop through the sub folders */
function getSubFolders(parent) {
  parent = parent.getId();
  var childFolder = DriveApp.getFolderById(parent).getFolders();
  while(childFolder.hasNext()) {
    var child = childFolder.next();
    Logger.log(child.getName());
    getSubFolders(child);
  }
  return;
}

/* End iterate through Sub Folders */

A:

How about instead of using SpreadsheetApp.create() use DriveApp.getFileById().makeCopy()?  Then you could have whatever scripts you wanted already in the spreadsheet when you make it.