It works now, I had to rewrite a lot of the script but it actually works way better. It wasn't checking that the battle ended and so it would just loop, and my check for it would 'sometimes' work so I just ended up rewriting it, thanks for letting me know!