The script doesn't do anything useful, just makes whoever has it immune to getting hit. It's just a boilerplate that I walk through in the video- the idea is that you would take that and add some logic of your own - like with O Ilusionista is doing.
My parry system is another example. I'll make a video on it when I can, but here's the quick rundown:
[list type=decimal]
[*]Every time the player presses block key, a global variable is populated with the elapsed time.
[*]When an entity's
doattackscript runs, it works almost exactly like I outline, but the line that sets
lasthitc to 0 is enclosed in another logic block. Immediately before that logic, my parry function is run.
[*]The parry function looks at current elapsed time and compares it to the last block press time recorded in step 1. If the the last press is within .25 second and a couple of other conditions pass (not busy doing something else, etc.), then the receiving entity's parry animation is played, the attacking entity gets a bit of delay time added to their current animation (this is in addition to whatever delay they already had), a visual block/parry flash is spawned, and the receiving entity gets a small MP boost. The function then returns a TRUE value. A little side note - mashing block won't work. There was no need to code in an anti mash check because in this module double tapping block triggers a backward dash. Side, SIDE note: I cheated while making the video by cranking the timing up to a full second.

[*]The extra logic block around lasthitc is just to verify if parry function returned true or false. If true, lasthitc is set to 0, and the attack is effectively nullified.
[/list]
You will find this to be far simpler and more effective than using the
takedamagescript or any other post action method. There's no need to go back and "undo" anything. The hit never happens at all, nor do any resulting scripts, flashes, and so on.
Also remember this runs on the attacker entity too. You could it set up a lot of pre-damage vectors. It's also useful for making "zones", where you essentially use the collision system to mark out portions of an area for custom behavior.
The order looks like this:
[list type=decimal]
[*]Hit detected
[*]Defender's DoAttack
[*]Attacker's DoAttack
[*]Lasthitc verify
[*]Default hit behavior
[/list]
HTH,
DC