I don't think it has anything to do with the script itself. I've made this exact script before elsewhere and it works perfectly. Somehow, it doesn't work during the battle.
Here is the script for when the battle starts. Everything inside of it works, it's just that it might be loading too much for other scripts to work.
https://pastebin.com/FY3w06V5