How would you code a script that makes a light flash on and off every 1/2 second if the player hit a key?
Similar questions have been answered numerous times here and other places. Try some googling.
You could set up a timer
You could set up a coroutine
You could use a repeating invoke
there are several ways to do this, and you should be able to google this