Hearts life 2D, how to make it invulnerable?

Hello, I am trying to create a Heart System for a 2D platform game but I am missing on how to create the Invulnerability for a couple of seconds or frames after getting hit. I have done this before but for Health Bars, not this system, my script so far goes like this for the player:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HealthPlayer : MonoBehaviour
{
public int health;
public int numOfHearts;

public Image[] hearts;
public Sprite fullHeart;
public Sprite emptyHeart;

public float timeInvincible = 10f;
bool isInvincible;
float invincibleTimer;

private void Update()
{
    for (int i = 0; i < hearts.Length; i++)
    {
        if (i < health)
        {
            hearts*.sprite = fullHeart;*

}
else
{
hearts*.sprite = emptyHeart;*
}
if (i < numOfHearts)
{
hearts*.enabled = true;*
}
else
{
hearts*.enabled = false;*
}
}
}
public GameObject deathEffect;
public void TakeDamage(int damage)
{
{
if (!isInvincible) { health -= damage; }
}

if (health <= 0)
{
Die();
}
}
void Die()
{
Instantiate(deathEffect, transform.position, Quaternion.identity);
Destroy(gameObject);
Time.timeScale = 0f;
}
}

you just need a timer in update that counts down - when its counting down set isinvincible to true - something along the lines of

if(invinsibleTime <= 0)
{
isinvincible = false;
}
else
{
isinvincible = ture;
invinsibleTime -= Time.fixedDeltatime;
}

when time runs out set it to false.