(SOLVED)Countdown from Trigger?

Hey there guys, ive gotten alot of help previously from these forums and i appreciate it greatly!

heres my question.

How can i make a “countdown” from a trigger?

i want to make a “speed boost” pickup, so i basically just made this for my trigger

function OnTriggerEnter (col : Collider) 
{ 
   var controller : FPSWalker = col.GetComponent(FPSWalker); 
    
   controller.speed = 350; 

}
@script RequireComponent(BoxCollider)

and then i threw this in my FPSWalker script

  while (speed >30){
      timeLeft = timeLeft - Time.deltaTime;
	if (timeLeft <= 0.0) 
   { 

	speed = 30;
   } }

is there a way to start the timer from when the trigger is triggered? at the moment it is just subtracting the time since the level started from my variable “timeLeft”

(i found this script on the forums somewhere, credits don’t go to me, thank you Idle_chris and Hogus)

thank you!

You need to reset the timer in the ‘on trigger enter’ function. Assuming ‘timeLeft’ is public, you should just be able to assign an appropriate value to it directly.

i ended up finding that if you put the timer in a boolean variable it doesn’t start until the boolean is true. so i made my Trigger just set my speed to greater than 30 and then threw this into my FPSWalker script:
( timeleft started with a value of 5, so i have a "5 second speed boost)

if (startTimer == true)
   { 
   timeLeft -= 1*Time.deltaTime; 
   
   }
   if (timeLeft <= 0.0) 
   { 
   speed = 30;
   startTimer = false; 
   } 
    if(timeLeft<=0) { 
   startTimer = false; 
   timeLeft = 5;
   }

thank you for the help though!