Picklecoderalt
If you want to define a variable named "body" for the complete script, yes, that's what you need. But I think the problem is something else here. You have a parameter named "body" in your_ on_body_entered function. But this "body" is not automatically the same as the variable you defined on top (so your $CharacterBody2D). It is whatever is passed to that function, and that depends on what the function is connected to. So I would be careful to call them both the same thing.
Can you check if the function is called at all? So if the event just doesn't trigger or if the if condition is somehow not met? Maybe just have a breakpoint or print directly before the if statement.