timer on muzzleflash

How would I create a timer when Fire1 is held down the timer starts n goes on for 0.02 seconds(something like that) and how would I put something like that into this script? I’ve checked the unity script reference on time.time and Deltatime, I have no idea how I would manage to put something like that into my script that starts a timer when fire1 is held down and if the timer reaches something like 0, then the flash is disabled(false). I seriously need aid with this…

{
	public GameObject flash;
	public Rigidbody Bulletprefab;
	public Transform barrelEnd;
	public int ammoPerClip = 12;
	public int Clips = 5;
	public AudioClip click;
	public float timeBetweenShots = 0.03f; //skott per sekund
	private float timestamp;
	public AudioClip reload;
	public Light skottljus;
	
	void Start()
	{
		skottljus.light.enabled = false;
		flash.renderer.enabled = false;
	}
	void Update () 
	{
		if (ammoPerClip <= 0) 
		{
			ammoPerClip = 0;
		}
		if (ammoPerClip == 0 && Input.GetKeyDown (KeyCode.R)) 
		{
			if(Clips >= 1)
			{
				audio.PlayOneShot(reload);
				ammoPerClip = 12;
				Clips--;
			}
		}
		if (Clips <= 0) 
		{
			Clips = 0;
		}
		if (Input.GetKeyDown (KeyCode.R) && Clips == 0 && ammoPerClip <= 0) 
		{
			ammoPerClip = 0;
		}

		if(Input.GetButtonDown("Fire1") && Time.time >= timestamp)
		{
			if(ammoPerClip > 0)
			{
				Rigidbody bulletInstance;
				bulletInstance = Instantiate(Bulletprefab, barrelEnd.position, barrelEnd.rotation) as Rigidbody;
				bulletInstance.AddForce(barrelEnd.forward * 6000);
				timestamp = Time.time + timeBetweenShots;
				audio.Play ();
				ammoPerClip--;
				flash.renderer.enabled = true;
				skottljus.light.enabled = true;

			}
		}
		if (ammoPerClip == 0 && Input.GetButtonDown ("Fire1")) 
		{
			audio.PlayOneShot(click);
		}
		if (Input.GetButtonUp ("Fire1")) 
		{
			flash.renderer.enabled = false;
			skottljus.light.enabled = false;
		}
	}

	void OnGUI()
	{
		GUI.Box (new Rect (1060, 475, 200, 100), "");
		GUI.Label(new Rect(1100,500,100,100), "Ammunition");
		GUI.Label(new Rect(1200,500,100,100), ammoPerClip.ToString());
		GUI.Label(new Rect(1100,525,100,100), "Magasin");
		GUI.Label(new Rect(1200,525,100,100), Clips.ToString());
	}
}

Is it possible to check if a button is
held down? if fire1 is held down then
timer starts…?

Yes, but that is not the way your code works. That is, your code currently checks for ‘Input.GetButtonDown()’, so right now your code fires one bullet each time the trigger is pulled. If you want to make a flash, then first create a function that turns off the renderer:

void FlashOff() {
    flash.renderer.enabled = false;
}

Then insert in your code somewhere between line 45 and line 55:

Invoke("FlashOff", 0.05);