How do I fix this "unexpected $end" error

I was trying to use Yanfly Ace Battle Engine script for my game, when suddenly this error message:

Script 'BattleManager' line 1405: SyntaxError ocurred.

unexpected $end, expecting keyword_end
end

So I searched online and I found that this error is fixed by putting and "end" command in the required line, so I did that, and the error still persists, I don't know why, can someone explain why this happens?

I attached an image to give you an idea of what it looks like.

EDIT: It was an error in the BattleManager, not in the Yanfly Script
I have moved this thread from RGSS3 Scripts (RMVX Ace) (as it is not a script release) to RGSSx Script Support.
So I searched online and I found that this error is fixed by putting and "end" command in the required line, so I did that, and the error still persists, I don't know why, can someone explain why this happens?
no do not put an end there.
That makes it worse.
You may have copied the battle engine script from yanfly incorrectly.
The base scripts are 100% working on their own. Adding another script is what you likely did wrong.

All custom scripts go near the bottom above main.
Where is the yanfly battle script located?
Where did you copy it from?
What version is it?
no do not put an end there.
That makes it worse.
You may have copied the battle engine script from yanfly incorrectly.
The base scripts are 100% working on their own. Adding another script is what you likely did wrong.

All custom scripts go near the bottom above main.
Where is the yanfly battle script located?
Where did you copy it from?
What version is it?
I tried putting it in another project and it didn't gave me the error

I guess it's because I made a change in the BattleManager script but I didn't remember it

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-fix-this-unexpected-end-error.163272/