How to unityscript, if GetButton wait some time?

The intent is to loop if button is down, to keep looping, but wait time before carrying out the rest of the function. Tried yeild wait for seconds, but doesnt work because update cannot be used as coroutine.

if (GetButton("Button")){

function waiting (){
yield WaitForSeconds (10.0);


Tried using StartCoroutine that yield WaitForTime, but doesnt do anything. The entire coroutine seems to make no difference or gets ignored. You would think it would.

This won’t work… I guess, maybe this could work for you, I didn’t test it.

float buttonDownTime = 0f;

void Update () {
    if (GetButtonDown("Button")){
        buttonDownTime += Time.deltaTime;
        if (buttonDownTime > timeNeed)
             //Do what you want
        buttonDownTime = 0;



you just need to delete “down” and now it will go through this statement when player hold the button

private var timer : float;
private var holding : false;
function Update () {
if (GetButtonDown(“Button”)){
print(“button was held for “+timer+” seconds”);
timer = 0;
//write some code

i dont full understand what you mean by:
but doesnt help with making it wait some time between.