"TypeError" "maybeTarget._character.eventId is not a function

Some of my players seem to be getting this error when entering certain maps with specific party members.
Apparently it is reproducable with the same party members once they go over a certain level.

"TypeError" "maybeTarget._character.eventId is not a function


What on earth could be causing this?
The maps it is happening on have no events, only an npc with a store.
It has to be something from a plugin you've installed or code you've added via script commands.

There is no code in the default MZ engine that uses a variable "maybeTarget".

To get any kind of real help, you need to reproduce the crash in a playtest, then press F8, go to the Console tab, and provide a screenshot of the error trace.
It has to be something from a plugin you've installed or code you've added via script commands.

There is no code in the default MZ engine that uses a variable "maybeTarget".

To get any kind of real help, you need to reproduce the crash in a playtest, then press F8, go to the Console tab, and provide a screenshot of the error trace.
Yeah I figured this is probably a plugin causing it somewhere, I'll have to get the save file and try to reproduce it. Thank you
have they only gotten one version of the game, or did you give them updates?

As said above there are many ways how a typeerror could have happened, but one of the more common causes is if you make a savefile under a game version and then switch to a different version that has a plugin added with such a command - only that the savefile cannot handle that because it is not compatible to the new game version.

Many plugins store their data into the savefile. That is the reason why adding a plugin can make an older savefile (that is missing that data) incompatible.
and if your players loaded an older savefile with such a case, it usually results in a type error when the added plugin needs its data.
Yeah I figured this is probably a plugin causing it somewhere, I'll have to get the save file and try to reproduce it. Thank you
It might also be a good idea to search all your plugin files for "maybeTarget" - whichever file you find this string in is probably the plugin where the error happens (and has a high chance of being the plugin causing the error). Judging by the name I'm guessing it's something battle-related.
have they only gotten one version of the game, or did you give them updates?

As said above there are many ways how a typeerror could have happened, but one of the more common causes is if you make a savefile under a game version and then switch to a different version that has a plugin added with such a command - only that the savefile cannot handle that because it is not compatible to the new game version.

Many plugins store their data into the savefile. That is the reason why adding a plugin can make an older savefile (that is missing that data) incompatible.
and if your players loaded an older savefile with such a case, it usually results in a type error when the added plugin needs its data.
This was also my initial thought since it often causes conflicts. But they are adamant they are on a fresh save.
It might also be a good idea to search all your plugin files for "maybeTarget" - whichever file you find this string in is probably the plugin where the error happens (and has a high chance of being the plugin causing the error). Judging by the name I'm guessing it's something battle-related.
Yeah, I'll have to do some digging in the meantime.
Hi @MGGEDev did you manage to solve this problem? I just faced it... It is the FilterControllerMZ plugin (in my case). My guess is that I forgot to "erase" one effect and now when I enter a place with a shopper it happens.

It is very strange. It works fine when I turn the plugin off, so I'm sure it related. But I really want to keep it on.
I just found a solution, in the case someone need it.

In the plugin, I replaced:

if (maybeTarget && maybeTarget._character &&
maybeTarget._character.eventId() === id) {
return maybeTarget;
}

with the following:

if (maybeTarget && maybeTarget._character &&
typeof maybeTarget._character.eventId === "function" &&
maybeTarget._character.eventId() === id) {
return maybeTarget;
}
Hi @MGGEDev did you manage to solve this problem? I just faced it... It is the FilterControllerMZ plugin (in my case). My guess is that I forgot to "erase" one effect and now when I enter a place with a shopper it happens.

It is very strange. It works fine when I turn the plugin off, so I'm sure it related. But I really want to keep it on.
This was indeed the issue. Sorry I forgot to update the thread to say I found the problem.
There was a filter I forgot to erase which was then causing the crashes.
I just found a solution, in the case someone need it.

In the plugin, I replaced:

if (maybeTarget && maybeTarget._character &&
maybeTarget._character.eventId() === id) {
return maybeTarget;
}

with the following:

if (maybeTarget && maybeTarget._character &&
typeof maybeTarget._character.eventId === "function" &&
maybeTarget._character.eventId() === id) {
return maybeTarget;
}
You're a chef !
I had the same issue, this worked perfectly
As this thread appears to be previously solved, it is now closed.

Original thread: https://forums.rpgmakerweb.com/threads/typeerror-maybetarget-_character-eventid-is-not-a-function.161270/