Welp, I either break this script one way or another.

Hello, So After completing a battle, it gives me the error. "Script 'Pokèmon Battle System' line 4355: TypeError occurred. nil can't be coerced into Fixnum


The Script:


https://gist.github.com/anonymous/ee4204432bef8aa2d5ab5d89c9c5ea03


I can get it to do nothing (no exp but no error) or I can get it to crash with this error.


I would appreciate it if somebody could help me figure out what's wrong.


Commenting out lines 4467-4485, 4322-4398. are what stop the crash but cause exp to stop working.
Hello, So After completing a battle, it gives me the error. "Script 'Pokèmon Battle System' line 4355: TypeError occurred. nil can't be coerced into Fixnum


The Script:


https://gist.github.com/anonymous/ee4204432bef8aa2d5ab5d89c9c5ea03


I can get it to do nothing (no exp but no error) or I can get it to crash with this error.


I would appreciate it if somebody could help me figure out what's wrong.


Commenting out lines 4467-4485, 4322-4398. are what stop the crash but cause exp to stop working.

Managed to solve it here is the fix for anybody who needs it https://gist.github.com/anonymous/33baa0f394a6beae9dee612efcc0502a

Original thread: https://forums.rpgmakerweb.com/threads/welp-i-either-break-this-script-one-way-or-another.63073/