When a function is called, make it stop what its doing and restart

Hey guys, i dont visit the help section often but ive been stuck on this for while, anyway is it possible to make it when a function is called, it stops what its currently doing restarts itself, or better, check if the function is using Yield Waitforseconds, and if it is, stop and restart the function. Im using this for multikills, ill put down an example of my code below, if you can help thankyou very much. :slight_smile:

//First Script
var script : SomeScript;
 
if(Input.GetKeyDown("e")) {
     script.Somefunction();
}
//SomeScript
var SomeInt : Int = 0;
 
function Somefunction () {
 
SomeInt += 1;
yield WaitForSeconds (4);
SomeInt = 0;
 
}

You can use StopCoroutine. There’s an example here:

Didn’t know how to use Coroutines in that sense, now i do! Thankyou.

//nevermind

Didn’t work?

Ah sorry, nevermind the post, i was going to ask how to mark the answer right, but then i realised im on the forums haha, it did, thankyou.