Summit's Gate - function doesn't work properly

so I made this function, and it works just fine at the beginning, but when I reach the third part of this level, it gives me the error like this:

just found the issue, I guess it’s because that the griffin has died but brought back to life by the warlock , so it can’t be counted as a real friend, is it right?

Problem has been solved, thanks!