How to execute code after X seconds

Hello. I know this question has been asked before but i couldnt get it to work properly
I am new in Unity and really bad at coding so that’s why I am asking something so obvious for some people like this… :frowning:

I have this code, in my FPS game, that i found on Youtube, where i want to give me ammo every 3 seconds if i come to the area. To specify this area I use a collider box. So i want to have this code executed every 3 seconds when being in the area that i mentioned above…

This is the code:
var AmmoPickUpSound : AudioSource;

function OnTriggerEnter (col : Collider) {
	if (GlobalAmmo.LoadedAmmo == 0) {
		GlobalAmmo.LoadedAmmo += 30;
	else {
	GlobalAmmo.CurrentAmmo += 30;

InvokeRepeating: Unity - Scripting API: MonoBehaviour.InvokeRepeating

Use it to execute the code the time you need.

u can using this


IEnumerator passiveMe(int secs)
    yield return new WaitForSeconds(secs);