UI Health point issue

unity said that int doesn’t have Length as a variable, but i have been following a video on how to do a health system and he got it to work. If there is something wrong with my code please tell me.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PlayerHealth : MonoBehaviour
{
public int health;

public int numOfHearts;

public Image[ ] hearts;

public Sprite heart;

void Start()
{

}

void Update()
{
numOfHearts = Mathf.Clamp(numOfHearts, 1, hearts.Length);
health = Mathf.Clamp(health, 0, numOfHearts);

for (int i = 0; i < health.Length; i++)
{
if (i < health)
{
health*.sprite = heart;*
}
if (i < numOfHearts)
{
hearts*.enabled = true;*
}
else
{
hearts*.enabled = false;*
}
}
}
}

Pretty sure you’re not copying the code correctly. He’s probably using hearts.Length not health.Length. Hearts is the array of heart images. I see several other places in the code where you don’t appear to have copied the code correctly either, specifically inside the for loop. Go back and watch very carefully what he types. You need to get everything exactly right or it won’t work.

Oh, i thought i put that there, Whoops! thank you