waitforseconds trouble

I have only been learning Unity for a short time so my coding and programming has been a bit of luck so far. Im trying to make a speed boost when the character collects/collides with an object.

function OnCollisionEnter (speedUpColl : Collision) {
     if(speedUpColl.gameObject.name == "Ship"){
        gameObject.Find("Ship").GetComponent(keyMovement).speed += 0.05;
        WaitForSeconds (3);
        gameObject.Find("Ship").GetComponent(keyMovement).speed -= 0.05;


that is my code so far. I want it so that 0.05 speed is added, then after a certain amount of seconds the speed is dropped off back to what it was. It makes sense in my head, but no clue how to put it into code.


Try putting yield in front of WaitForSeconds... If I remember correctly that's needed...



That should work...