Need help with implementing attack speed/delay

Hi,
Can anyone help me with implementing a delay between every attack?

Right now my code;

  • Checks if enemy is within range
  • Calls attack method while enemy is within attack range

How can I implement an attack speed/delay so that the enemy does not attack constantly?

There’s an example using Time.time the unity script ref, I’ve adapted this a couple of times for my projects.

Linkage