Check if the flag "enemy" is off.
Stats - Target Allowed
Now tick the "Enemy" box.
Hmmm use trigger to check if target unit belongs to an ally of owner of casting unit. And yeah, nowadays triggers are everything, normal object editing is becoming harder and harder to manipulate as spell ideas get more advanced.
Unit begins casting an ability
ability equal to cast is equal to (your ability)
owner of target of ability begin cast is an enemy equal to true
make casting unit stop