copied the code ofc from gdquest
Ok, this is far from obvious (as you seem to imply by using "ofc") and some valuable information that should've been part of the question from the outset!
I did not Understand most of the code if not all of it
Then that is what you should work on first! No point in trying to run a marathon, before you learned how to walk. Nobody will teach you the former first!
ik this is too far for a beginner but...
Change the "but" into a period: this is too far for a beginner! To be clear: I don't think this is complicated at all. What makes it complicated is the fact that you choose to copy a codebase that you do not understand and the fact that you claim to have no former experience with Godot or programming in general.
The answer to your question is: keep track of the direction your character is moving, multiply that direction with a factor of 1 by default and by -0.5 (halved as you want to back up slower than the enemy, inverted as you're moving backwards) as long as the raycast is colliding with an enemy. Of course things become more complicated when you're using a pathfinding-algorithm on top of it, but there is no way to answer that in a general and concise manner here given the information you provided.
and also i making another game at the same time
Completely different topic. Create a new question for that as recommended here:
If you have several questions, open several topics. Do not ask several unrelated questions in the same thread, as it will be harder to give you a proper answer for each point.
That being said, the solution is to use an array to keep track of all bodies inside the area individually. Check out my answer over here.