Cannot read property of split() undefined

Hello, I am quite new to p5js (on and off for the past few months) but as of recently, I have run into a problem that myself nor my peers or teacher can solve. We are working on an application that is like a word per minute game and we are using split() to separate user input which is normally a string and trying to store each word into an array. We solved the problem by copying the code into a new p5js file and that worked for a week until the error came back. We have no clue what do any help is appreciated. Please note that I had to delete a lot of the getUserFunctions because there was over 100000 characters in the code, but it is the same idea. Any help is appreciated.

var drawButton
var drawButton2;
var drawButton3;

var drawButton4;
var drawButton5;
var drawButton6;
var drawButton7;
var drawButton8;
var drawButton9;

var drawButton10;
var drawButton11;
var drawButton12;
var drawButton13;
// var drawButton14;
// var drawButton15;

// var drawButton16;
// var drawButton17;
// var drawButton18;
// var drawButton19;
// var drawButton20;
// var drawButton21;

// var drawButton22;
// var drawButton23;
// var drawButton24;
// var drawButton25;
// var drawButton26;
// var drawButton27;

// var drawButton28;
// var drawButton29;
// var drawButton30;
// var drawButton31;
// var drawButton32;
// var drawButton33;

// var drawButton34;
// var drawButton35;
// var drawButton36;
// var drawButton37;
// var drawButton38;
// var drawButton39;

// var drawButton40;
// var drawButton41;
// var drawButton42;
// var drawButton43;
// var drawButton44;
// var drawButton45;

// var drawButton46;
// var drawButton47;
// var drawButton48;
// var drawButton49;
// var drawButton50;

var beginButton;

var btnCount;

var output;

var input; 
var runCount = 0;

var correctScore = 0;
var checkingArrayNum = 0;
var incorrectScore = 0;

var sentencesPressedCount = 0;

var counter = 0;
var timeLeft = 60;


var forest;
var forest2;
var forest3;
var forest4;
var forest5;
var backgroundMusic;
var incorrectWordMusic;
var num = 0;

var percentCorrect = 0;

function preload(){
  //Lines 200 - 204 take previously declared variables and assign images to them
   forest = loadImage('img/forest.jpg')
   forest2 = loadImage('img/forest2.jpg')
   forest3= loadImage('img/forest3.jpg')
   forest4 = loadImage('img/forest4.jfif')
   forest5 = loadImage('img/forest5.jfif')
  //Lines 205 assigns a song to the variable backgroundMusic
  // backgroundMusic = loadSound('music/music_zapsplat_game_music_kids_warm_soft_slow_chilled_piano_bass_warm_pads_vocal_ahs_022.mp3');
  incorrectWordMusic = loadSound('music/Fireworks, rocket whistle.wav')

}

var sentenceArray2 = ["The", "flag", "was", "red,", "white,",  "and", "blue."];
var sentenceString2 = "The flag was red, white, and blue."

var sentenceArray3 = ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog."]
var sentenceString3 = "The quick brown fox jumps over the lazy dog."

var sentenceArray4 = ["Cats", "are", "good", "pets,", "for", "they", "are", "clean", "and", "are", "not", "noisy."];
var sentenceString4 = "Cats are good pets, for they are clean and are not noisy.";

var sentenceArray5 = ["I", "want", "to", "buy", "a", "onesie...", "but", "know", "it", "won't", "suit", "me."];
var sentenceString5 = "I want to buy a onesies... but know it won't suit me."

var sentenceArray6 = ["That", "was", "how", "he", "came", "to", "win", "$1", "million."];
var sentenceString6 = "That was how he came to win $1 million.";

var sentenceArray7 = ["The", "Secret", "ingredient", "to", "his", "wonderful", "life", "was", "crime."];
var sentenceString7 = "The secret ingredient to his wonderful life was crime."

var sentenceArray8 = ["It's", "not", "often", "you", "find", "a", "soggy", "banana", "on", "the", "street."];
var sentenceString8 = "It's not often you find a soggy banana on the stree."

var sentenceArray9 = ["The", "waves", "were", "crashing", "on", "the", "shore;", "it", "was", "a", "lovely", "sight."]
var sentenceString9 = "The waves were crashing on the shore; it was a lovely sight."

var sentenceArray10 = ["No", "matter", "how", "beatiful", "the", "sunset,", "it", "saddened", "her", "knowing", "she", "was", "one", "day", "older."]
var sentenceString10 = "No matter how beatiful the sunset, it saddened her knowing she was one day older."

var sentenceArray11 = ["She", "could", "hear", "him", "in", "the", "shower", "singing", "with", "a", "joy", "she", "hoped", "he'd", "retain", "after", "she", "delivered", "the", "news."]
var sentenceString11 = "She could hear him in the shower singing with a joy she hoped he'd retain after she delivered the news."

var sentenceArray12 = ["Two", "seats", "were", "vacant."]
var sentenceString12 = "Two seats were vacant."

var sentenceArray13 = ["The", "oppurtunity", "of", "a", "lifetime", "passed", "before", "him", "as", "he", "tried", "to", "decide", "between", "a", "cone", "or", "a", "cup."]
var sentenceString13 = "The oppurtunity of a lifetime passed before him as he tried to decide between a cone or a cup."

var sentenceArray14 = ["Mary", "plays", "the", "piano."]
var sentenceString14 = "Mary plays the piano."

var sentenceArray15 = ["It", "took", "him", "a", "while", "to", "realize", "that", "everything", "he", "decided", "not", "to", "change,", "he", "was", "actually", "choosing."]
var sentenceString15 = "It took him a while to realize that everything he decided not to change, he was actually choosing."

var sentenceArray16 = ["His", "ultimate", "dream", "fantasy", "consisted", "of", "being", "content", "and", "sleeping", "eight", "hours", "in", "a", "row."]
var sentenceString16 = "His ultimate dream fantasy consisted of being content and sleeping eight hours in a row."

var sentenceArray17 = ["The", "three-year-old", "girl", "ran", "down", "the", "beach", "as", "the", "kite", "flew", "behind", "her."]
var sentenceString17 = "The three-year-old girl ran down the beach as the kite flew behind her."

var sentenceArray18 = ["Green", "should", "have", "smelled", "more", "tranquil,", "but", "somehow", "it", "just", "tasted", "rotten."]
var sentenceString18 = "Green should have smelled more tranquil, but somehow it just tested rotten."

var sentenceArray19 = ["Mothers", "spend", "months", "of", "their", "lives", "waiting", "on", "their", "children."]
var sentenceString19 = "Mothers spend months of their lives waiting on their children."

var sentenceArray20 = ["Having", "no", "hair", "made", "him", "look", "even", "harrier."]
var sentenceString20 = "Having no hair made him look even harrier."

var sentenceArray21 = ["You're", "unsure", "whether", "or", "not", "to", "trust", "him,", "but", "very", "thankful", "that", "you", "wore", "a", "turtle", "neck."]
var sentenceString21 = "You're unsure whether or not to trust him but very thankful that you wore a turtle neck."

var sentenceArray21 = ["Now", "I", "need", "to", "ponder", "my", "existence", "and", "ask", "myself", "if", "I'm", "truly", "real"]
var sentenceString21 = "Now I need to ponder my existence and ask myself if I'm truly real"

var sentenceArray22 = ["People", "who", "insist", "on", "picking", "their", "teeth", "with", "their", "elbows", "are", "so", "annoying."]
var sentenceString22 = "People who insist on picking their teetth with their elbows are so annoying."

var sentenceArray23 = ["He", "decided", "water-skiing", "on", "a", "frozen", "lake", "wasn't", "a", "good", "idea."]
var sentenceString23 = "He decided water-skiing on a frozen lake wasn't a good idea."

var sentenceArray24 = ["He", "waited", "for", "the", "stop", "sign", "to", "turn", "to", "a", "go", "sign."]
var sentenceString24 = "He waited for the stop sign to turn to a go sign."

var sentenceArray25 = ["He", "uses", "onomatopoeia", "as", "a", "weapon", "of", "mental", "destruction."]
var sentenceString25 = "He uses onomatopoeia as a weapon of mental destruction."

var sentenceArray26 = ["A", "dead", "duck", "doesn't", "fly", "backward."]
var sentenceString26 = "A dead duck doesn't fly backward."

var sentenceArray27 = ["Truth", "in", "advertising", "and", "dinosaurs", "with", "skateboards", "have", "much", "in", "common."]
var sentenceString27 = "Truth in advertising and dinosaurs with skateboards have much in common."

var sentenceArray28 = ["The", "fox", "in", "the", "tophat", "whispered", "into", "the", "ear", "of", "the", "rabbit."]
var sentenceString28 = "The fox in the tophat whispered into the ear of the rabbit."

var sentenceArray29 = ["If", "any", "cop", "asks", "you", "where", "you", "were,", "just", "say", "you", "were", "visiting", "Kansas."]
var sentenceString29 = "If any cop asks you where you were, just say you were visiting Kansas."

var sentenceArray30 = ["The", "thick", "foilage", "and", "intertwined", "vines", "made", "the", "hike", "nearly", "impossible."]
var sentenceString30 = "The thick foilage and intertwined vines made the hike nearly impossible."

var sentenceArray31 = ["I", "ate", "a", "sock", "because", "people", "on", "the", "internet", "told", "me", "to."]
var sentenceString31 = "I ate a sock because people on the internet told me to."

var sentenceArray32 = ["He", "spiked", "his", "hair", "green", "to", "support", "his", "iguana."]
var sentenceString32 = "He spiked his hair green to support his iguana."

var sentenceArray33 = ["They", "desperately", "needed", "another", "drummer", "since", "the", "current", "one", "only", "knew", "how", "to", "play", "bongos."]
var sentenceString33 = "They desperately needed another drummer since the current one only knew how to play bongos."

var sentenceArray34 = ["The", "tattered", "work", "gloves", "speak", "of", "the", "many", "hours", "of", "hard", "labour", "he", "endured", "throughout", "his", "life."]
var sentenceString34 = "The tattered work gloves speak of the many hours of hard labour he endured throughout his life."

var sentenceArray35 = ["It", "was", "the", "security", "that", "fueled", "his", "creativity."]
var sentenceString35 = "It was the security that fueled his creativity."

var sentenceArray36 = ["Last", "Friday", "I", "saw", "a", "spotted", "striped", "blue", "worm", "shake", "hands", "with", "a", "legless", "lizard."]
var sentenceString36 = "Last Friday I saw a spotted striped blue worm shake hands with a legless lizard."

var sentenceArray37 = ["They", "looked", "up", "at", "the", "sky", "and", "saw", "a", "million", "stars."]
var sentenceString37 = "They looked up at the sky and saw a million stars."

var sentenceArray38 = ["Various", "sea", "birds", "are", "elegant,", "but", "nothing", "is", "as", "elegant", "as", "a", "gliding", "pelican."]
var sentenceString38 = "Various sea birds are elegant, but nothing is as elegant as a gliding pelican."

var sentenceArray39 = ["I", "may", "struggle", "with", "geography,", "but", "I'm", "sure", "I'm", "somewhere", "around", "here."]
var sentenceString39 = "I may struggle with geography, but I'm sure I'm somewhere around here."

var sentenceArray40 = ["He", "had", "decided", "to", "accept", "his", "fate", "of", "accepting", "his", "fate."]
var sentenceString40 = "He had decided to accept his fate of accepting his fate."

var sentenceArray41 = ["The", "minute", "she", "landed", "she", "understood", "the", "reason", "this", "was", "a", "fly-over", "state."]
var sentenceString41 = "The minute she landed she understoof the reason this a fly-over state."

var sentenceArray42 = ["Nothing", "is", "as", "cautiously", "cuddly", "as", "a", "pet", "porcupine."]
var sentenceString42 = "Nothing is as cautiously cuddly as a pet porcupine."

var sentenceArray43 = ["We", "have", "never", "been", "to", "Asia,", "nor", "have", "we", "visited", "Africa."]
var sentenceString43 = "We have never been to Asia nor have we visited Africa."

var sentenceArray44 = ["The", "Japanese", "yen", "for", "commerce", "is", "still", "well-known."]
var sentenceString44 = "The Japanese yen for commerce is still well-known."

var sentenceArray45 = ["She", "wrote", "him", "a", "long", "letter,", "but", "he", "didn't", "read", "it."]
var sentenceString45 = "She wrote him a long letter, but he didn't read it."

var sentenceArray46 = ["The", "murder", "hornet", "was", "disappointed", "by", "the", "preconceived", "ideas", "people", "had", "of", "him."]
var sentenceString46 = "The murder hornet was disappointed by the preconceived ideas people had of him."

var sentenceArray47 = ["It's", "much", "more", "difficult", "to", "play", "tennis", "with", "a", "bowling", "ball", "than", "it", "is", "to", "bowl", "with", "a", "tennis", "ball."]
var sentenceString47 = "It's much more difficult to play tennis with a bowling ball than it is to bowl with a tennis ball."

var sentenceArray48 = ["He", "stepped", "gingerly", "onto", "the", "bridge", "knowing", "that", "enchantment", "awaited", "on", "the", "other", "side."]
var sentenceString48 = "He stepped gingerly onto the bridge knowing that enchantment awaited on the other side."

var sentenceArray49 = ["He", "wasn't", "bitter", "that", "she", "had", "moved", "on", "but", "from", "the", "radish."]
var sentenceString49 = "He wasn't bitter that she had moved on but from the radish."

//This function will convert seconds to minutes and get the remainder of converting seconds to minutes and format it such as 00:00
function convertSeconds(s){
  //To get minutes we have to divide seconds by 60 and floor it
  var min = floor(s/60)
  //To get seconds we have to find the remainder of seconds divided by minutes
  var sec = s % 60
  //This just formates the numbers so it looks nice
  return nf(min,2) + ":" + nf(sec,2);
}


function beginTimer(){
  //backgroundMusic.play();
  var params = getURLParams();
  if(params.minute){
    var min = params.minute
    timeLeft = min * 60;
  }
  //Referncing html .timer class 
  var timer=select('.timer');
  timer.html(convertSeconds(timeLeft-counter))
  
  var interval = setInterval(timeIt, 1000);

  //Actually updates the timer
  function timeIt(){
    //Increases the counter
    counter++;
    //Subtracts the time of timeLeft by counter
    timer.html(convertSeconds(timeLeft-counter));
    //When timeLeft == 0  do all of this
    if(counter == timeLeft){
      print('hello')
      clearInterval(interval);
      //createCanvas(-1500, 2000);
      //background(200);
      //counter = 0;
      fill(200, 40, 50);
      sentencesPressedCount = sentencesPressedCount / 2;
      print("The actual amount of sentence buttons pressed is: " + sentencesPressedCount)
      fixedIncorrectScore = incorrectScore;
            percentCorrect = (correctScore / (correctScore + fixedIncorrectScore)) * 100;
      var drawPercentButton = createButton("Percent Correct: " + percentCorrect + "%");
      drawPercentButton.position(530, 900) //210, 1230 OR 540, 1230
      drawPercentButton.style('color: orange;');
      drawPercentButton.style('background-color: black;');
      drawPercentButton.style('font-size: 20px;');
      drawPercentButton.size(160, 80);
      var drawInocrrectButton = createButton("Incorrect Score: " + fixedIncorrectScore);
      drawInocrrectButton.position(530, 1000) //210, 1230 OR 540, 1230
      drawInocrrectButton.style('color: orange;');
      drawInocrrectButton.style('background-color: black;');
      drawInocrrectButton.style('font-size: 20px;');
      drawInocrrectButton.size(160, 80);
      var drawCorrectButton = createButton("Correct Score: " + correctScore);
      drawCorrectButton.position(530, 1100) //210, 1230 OR 540, 1230
      drawCorrectButton.style('color: orange;');
      drawCorrectButton.style('background-color: black;');
      drawCorrectButton.style('font-size: 20px;');
      drawCorrectButton.size(160, 80);
      // text("btnCount: " + btnCount, 2, 5);
    }
    
  }
}










function setup() {
  createCanvas(1130, 100); //1130
  
   var button = select('.submit');
  button.mousePressed(getUserSentence);
  input = select('.userInput');
  
  var button2 = select('.submit2');
  button2.mousePressed(getUserSentence2);
    input = select('.userInput');

  var button3 = select('.submit3');
  button3.mousePressed(getUserSentence3);
  input = select('.userInput');
  
    var button4 = select('.submit4');
  button4.mousePressed(getUserSentence4);
  input = select('.userInput');
  
  var button5 = select('.submit5')
  button5.mousePressed(getUserSentence5);
  input = select('.userInput')
  
  var button6 = select('.submit6')
  button6.mousePressed(getUserSentence6);
  input = select('.userInput')
  
  var button7 = select('.submit7')
  button7.mousePressed(getUserSentence7);
  input = select('.userInput')
  
  var button8 = select('.submit8')
  button8.mousePressed(getUserSentence8);
  input = select('.userInput')
  
  var button9 = select('.submit9')
  button9.mousePressed(getUserSentence9);
  input = select('.userInput')

  var button10 = select('.submit10')
  button10.mousePressed(getUserSentence10);
  input = select('.userInput')
  
  var button11 = select('.submit11')
  button11.mousePressed(getUserSentence11);
  input = select('.userInput')
  
   var button12 = select('.submit12')
  button12.mousePressed(getUserSentence12);
  input = select('.userInput')
  
  var button13 = select('.submit13')
  button13.mousePressed(getUserSentence13);
  input = select('.userInput')
  
  var button14 = select('.submit14')
  button14.mousePressed(getUserSentence14);
  input = select('.userInput')
  
  var button15 = select('.submit15')
  button15.mousePressed(getUserSentence15);
  input = select('.userInput')
  
  var button16 = select('.submit16')
  button16.mousePressed(getUserSentence16);
  input = select('.userInput')
  
  var button17 = select('.submit17')
  button17.mousePressed(getUserSentence17);
  input = select('.userInput')
  
  var button18 = select('.submit18')
  button18.mousePressed(getUserSentence18);
  input = select('.userInput')
  
  var button19 = select('.submit19')
  button19.mousePressed(getUserSentence19);
  input = select('.userInput')
  
  var button20 = select('.submit20')
  button20.mousePressed(getUserSentence20);
  input = select('.userInput')
  
  var button21 = select('.submit21')
  button21.mousePressed(getUserSentence21);
  input = select('.userInput')
  
  var button22 = select('.submit22')
  button22.mousePressed(getUserSentence22);
  input = select('.userInput')
  
  var button23 = select('.submit23')
  button23.mousePressed(getUserSentence23);
  input = select('.userInput')
  
  var button24 = select('.submit24')
  button24.mousePressed(getUserSentence24);
  input = select('.userInput')

  var button25 = select('.submit25')
  button25.mousePressed(getUserSentence25);
  input = select('.userInput')

  var button26 = select('.submit26')
  button26.mousePressed(getUserSentence26);
  input = select('.userInput')
  
  var button27 = select('.submit27')
  button27.mousePressed(getUserSentence27);
  input = select('.userInput')
  
  var button28 = select('.submit28')
  button28.mousePressed(getUserSentence28);
  input = select('.userInput')
  
  var button29 = select('.submit29')
  button29.mousePressed(getUserSentence29);
  input = select('.userInput')
  
  var button30 = select('.submit30')
  button30.mousePressed(getUserSentence30);
  input = select('.userInput')
  
  var button31 = select('.submit31')
  button31.mousePressed(getUserSentence31);
  input = select('.userInput')
  
  var button32 = select('.submit32')
  button32.mousePressed(getUserSentence32);
  input = select('.userInput')
  
  var button33 = select('.submit33')
  button33.mousePressed(getUserSentence33);
  input = select('.userInput')

  var button34 = select('.submit34')
  button34.mousePressed(getUserSentence34);
  input = select('.userInput')
  
  var button35 = select('.submit35')
  button35.mousePressed(getUserSentence35);
  input = select('.userInput')
  
   var button36 = select('.submit36')
  button36.mousePressed(getUserSentence36);
  input = select('.userInput')
  
  var button37 = select('.submit37')
  button37.mousePressed(getUserSentence37);
  input = select('.userInput')
  
  var button38 = select('.submit38')
  button38.mousePressed(getUserSentence38);
  input = select('.userInput')
  
  var button39 = select('.submit39')
  button39.mousePressed(getUserSentence39);
  input = select('.userInput')
  
  var button40 = select('.submit40')
  button40.mousePressed(getUserSentence40);
  input = select('.userInput')
  
  var button41 = select('.submit41');
  button41.mousePressed(getUserSentence41);
  input = select('.userInput')
  
  var button42 = select('.submit42')
  button42.mousePressed(getUserSentence42);
  input = select('.userInput')
  
  var button43 = select('.submit43')
  button43.mousePressed(getUserSentence43);
  input = select('.userInput')
  
  var button44 = select('.submit44')
  button44.mousePressed(getUserSentence44);
  input = select('.userInput')
  
  var button45 = select('.submit45')
  button45.mousePressed(getUserSentence45);
  input = select('.userInput')
  
  var button46 = select('.submit46')
  button46.mousePressed(getUserSentence46);
  input = select('.userInput')
  
  var button47 = select('.submit47')
  button47.mousePressed(getUserSentence47);
  input = select('.userInput')
  
  var button48 = select('.submit48')
  button48.mousePressed(getUserSentence48);
  input = select('.userInput')

  // var button49 = select('.submit49')
  // button49.mousePressed(getUserSentence49);
  // input = select('.userInput')
  
    var beginButton = select('.startTimer')
  beginButton.mousePressed(beginTimer);

}

function getUserSentence(){
  //beginButton.hide();
  checkingArrayNum = 0;
  sentencesPressedCount = sentencesPressedCount + 0.5;  
  //print("This is how many sentences where pressed: " + sentencesPressedCount)
  //Lines 550-558. This line draws a button that contains a String that is from a globally declared variable. 
  var num2 = 2;
  if(num2 == 2){
    var drawButton2 = createButton(sentenceString2);
    drawButton2.position(250, 150) //210, 1230 OR 540, 1230
    drawButton2.style('color: orange;');
    drawButton2.style('background-color: black;');
    drawButton2.style('font-size: 20px;');
    drawButton2.size(1000, 60);
  }
  
  //Gets user in put from the text box when they hit submit
  var actualUserText = input.value();
  
  //Lines 563-568. These lines declare var r as a space. and then seperates the string words by a space. Then we use a for     loop to find how many words there are because we know how many spaces there are. By knowing how many spaces their are       there we know how many words there are. 
  var r = /\s/;
  var words = actualUserText.split(r);
  print(words);
  for(var i = 0; i < words.length; i++){
    print(words[i]);
  }

    //Checks the Array words and the Array sentenceArray1 to see if each word is correct or not
    //If they word the user enters matches the position and value of sentance array then the correct score increases by 1
    //If the word doesnt match the position or value of the sentence array then the incorrect score increase by 1.
    while(checkingArrayNum == 0){
      for(var i2 = 0; i2 < words.length && i2 < sentenceArray2.length; i2++){
        if(words[i2] == sentenceArray2[i2]){
          print(words[i2] + " is equal too " + sentenceArray2[i2])
          correctScore = correctScore + 1;
        }else if(words[i2] != sentenceArray2.length[i2]){
          print(words[i2] + " is not equal too " + sentenceArray2[i2])
          incorrectWordMusic.play();
          incorrectScore = incorrectScore + 1;
        }
        checkingArrayNum = checkingArrayNum + 1;
      }
    }
    //Line 586. This line fixes the incorrect score due to a double button press problem. 
    incorrectScore = incorrectScore - 0.5;
    print("The incorrect score is " + incorrectScore);
    print("The correct score is " + correctScore);
  
    //Lines 591 and 592. These lines clear in the input field when the user clicks on the button so they do not have to         manually click it. This is also known as manipulating the dom in javascript.
    var btnClear = document.querySelector('button.submit');
    let inputs = document.querySelectorAll('input');
    
    //Lines 595-597. These lines add an event listener to each button and retrives the input the user entered when they         click on the button.
    btnClear.addEventListener('click',()=>{
    inputs.forEach(input => input.value = '');
    btnCount = btnCount + 1;
  });
}




function getUserSentence2(){
  sentencesPressedCount = sentencesPressedCount + 1;  
  var num2 = 3
    if(num2 == 3){
      var drawButton3 = createButton(sentenceString3);
      drawButton3.position(250, 150); //210, 1230 OR 540, 1230
      drawButton3.style('color: orange;');
      drawButton3.style('background-color: black;');
      drawButton3.style('font-size: 20px;');
      drawButton3.size(1000, 60);
    }
  
  var checkingArrayNum2 = 0;
  
  //Gets user in put from the text box when they hit submit
  var actualUserText = input.value();

  var r = /\s/;
  var words3 = actualUserText.split(r);
  print(words3);
  for(var i = 0; i < words3.length; i++){
    print(words3[i]);
  }
  
  while(checkingArrayNum2 == 0){
    for(var i4 = 0; i4 < words3.length && i4 < sentenceArray3.length; i4++){
      if(words3[i4] == sentenceArray3[i4]){
        print(words3[i4] + " is equal too " + sentenceArray3[i4])
        correctScore = correctScore + 1;
      }else if(words3[i4] != sentenceArray3.length[i4]){
        print(words3[i4] + " is not equal too " + sentenceArray3[i4])
        incorrectWordMusic.play();
        incorrectScore = incorrectScore + 1;
      }
    }
   checkingArrayNum2 = checkingArrayNum2 + 1;
  }
  incorrectScore = incorrectScore -0.5;
  print("The incorrect socre is " + incorrectScore);
  print("The correct score " + correctScore);
  // text("Correct score: " + correctScore, 4, 20);
  // text("Incorrect score: " + incorrectScore, 0,10);
  
  var btnClear = document.querySelector('button.submit2');
  let inputs = document.querySelectorAll('input');
  
  btnClear.addEventListener('click',()=>{
  inputs.forEach(input => input.value = '');
  });
}

function getUserSentence3(){
  sentencesPressedCount = sentencesPressedCount + 1;
  var num2 = 4
    if(num2 == 4){
      var drawButton4 = createButton(sentenceString4);
      drawButton4.position(250, 150) //210, 1230 OR 540, 1230
      drawButton4.style('color: orange;');
      drawButton4.style('background-color: black;');
      drawButton4.style('font-size: 20px;');
      drawButton4.size(1000, 60);
    }
  
  var checkingArrayNum4 = 0;
  
  //Gets user in put from the text box when they hit submit
  var actualUserText = input.value();

  var r = /\s/;
  var words4 = actualUserText.split(r);
  print(words4);
  for(var i = 0; i < words4.length; i++){
    print(words4[i]);
  }
  
  while(checkingArrayNum4 == 0){
    for(var i4 = 0; i4 < words4.length && i4 < sentenceArray4.length; i4++){
      if(words4[i4] == sentenceArray4[i4]){
        print(words4[i4] + " is equal too " + sentenceArray4[i4])
        correctScore = correctScore + 1;
      }else if(words4[i4] != sentenceArray4.length[i4]){
        print(words4[i4] + " is not equal too " + sentenceArray4[i4])
        incorrectWordMusic.play();
        incorrectScore = incorrectScore + 1;
      }
    }
   checkingArrayNum4 = checkingArrayNum4 + 1;
  }
  incorrectScore = incorrectScore - 0.5;
  print("The incorrect socre is " + incorrectScore);
  print("The correct score " + correctScore);
 
  var btnClear = document.querySelector('button.submit3');
  let inputs = document.querySelectorAll('input');
  
  btnClear.addEventListener('click',()=>{
  inputs.forEach(input => input.value = '');
  });
}

What was the error and in which line (and which variable) did it occur?

Did you try saving a copy with a new name?

Did you try to run it in the processing IDE (download)?

The type split is undefined for line 186. And yes I tried saving to a different file with different name