Undefined error problem

Hi, I’m facing an undefined error problem in my game. I have no idea how to fix it as I have the same code written in some other chapters but it seems to be working in those.

Forum- 2
This is the error that I’m getting.

Where and how did you initialize $history to an array?

<<set $history = []>> This is how I’m initializing

And where, specifically what passage, are you doing that?