How to cancel skills while they are being cast in this system?

I am trying to make it so that if the player gets hit while casting a skill the skill will get cancelled. Right now it just glitches and player gets stuck until he uses the skill again. The system works this way:

Tool is equipped. When V is pressed, a remote event “VEnabled” is sent to the server script. When VEnabled is sent, “Holding.Value” changes to “V” and some stuff like player movespeed is changed to 0 as the skill is being casted. When holding value changes, the local script detects its value and if it is V, the V animation is being played. Once it reaches the required marker, it fires the event “V” and the skill is casted.

All input codes are connected to a “if disabled.Value == true then return end” and every player after being hit have their disabled.Value enabled, and then disabled after like a second. What I want to do is to make it so that the skills will cancel while they are being casted if the disabled.Value becomes true. But I don’t really know how to do that. Any ideas?

The idea would be to detect a hit and reverse all changes. Implementation really depends on your game and you

Where should I add that to? Into the tool server script? A local script?