# Functions cannot load (Tic tac toe)

**URL:** https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561
**Category:** Coding Questions
**Created:** [April 22, 2021, 4:22pm UTC](https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561 "2021-04-22T16:22:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JustinChan613](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JustinChan613](https://discourse.processing.org/u/JustinChan613)
#### Post date: [April 22, 2021, 4:22pm UTC](https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561/1 "2021-04-22T16:22:51Z")

</div>

Hi all I am continuing my tic tac toe project while I meet another problem. When I load the functions, the system keeps responding ‘Uncaught RangeError: Maximum call stack size exceeded’ or ‘Cannot read property ‘NaN’ of undefined’ on function mousePressed( ). Would like to ask what the problem is and how to solve it. Thanks!

[https://editor.p5js.org/JustinChan/sketches/fYyMbAdJB](https://editor.p5js.org/JustinChan/sketches/fYyMbAdJB)

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [April 22, 2021, 4:34pm UTC](https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561/2 "2021-04-22T16:34:31Z")

</div>

Hello,

You are calling `aiTurn()` inside of `mousePressed()` which in turn call `mousePressed()`. You are creating an infinite loop and that’s why you have a stack overflow.

---

<div class="post-metadata">

### Author: ![JustinChan613](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JustinChan613](https://discourse.processing.org/u/JustinChan613)
#### Post date: [April 22, 2021, 6:54pm UTC](https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561/3 "2021-04-22T18:54:48Z")

</div>

Thank you! I then remove the mousePressed( ) in aiTurn( ). But then I cannot put the cross in it. When I have already indicated HumanCurrentPlayer = true in aiTurn( ), it should be working. Would like to ask why is it happening and how to solve it? Thanksss.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 22, 2021, 6:57pm UTC](https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561/4 "2021-04-22T18:57:25Z")

</div>

Just take a moment to solve it on your own

---

<div class="post-metadata">

### Author: ![JustinChan613](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JustinChan613](https://discourse.processing.org/u/JustinChan613)
#### Post date: [April 22, 2021, 7:02pm UTC](https://discourse.processing.org/t/functions-cannot-load-tic-tac-toe/29561/5 "2021-04-22T19:02:19Z")

</div>

yah sure will do it thank you btw
