How to stop a function while colliding with the character

What exactly is wrong?
I mean the bp looks fine