I’ve made a game of hangman, but it says IndexOutOfRangeException: Array index is out of range.
The error appears in here:
MainGameScript.ChooseWord()
MaingameScript.RestartGame()
MainGameScript.Start()
The problem is probably in this piece of script:
void RestartGame()
{
winorlose.enabled = false;
gameLost = false;
gameWinner = 0;
wrongAnswer = 0;
for (int i = 0; i < hangmanWords.Length; i++) {
hangmanWords *.GetComponent<Text> ().text = "_";*
_ hangmanWords .SetActive (false);_
* }*
* for (int i = 0; i < hangman.Length; i++) {*
_ hangman .SetActive (false);
* }*_
* ChooseWord ();*
* }*
Could you please help me with this? If this isn’t the right piece of script, please let me know.