Help with a low health script

Hello I need help with a low health script. I have a gameobject with a health text value and I am trying to play a sound on low health. The script I am trying to use below:

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

public class Test : MonoBehaviour {
    public Text health;
    public AudioSource mysound;
    
        
    void Update () {
    
	if (health=5) {
		mysound.Play();
    
    }
}

I drag my playerhealthtext into the public health field create an audiosource but I can’t get it to work. Any ideas how I can implement this?

Hello.

I think you need to watch some tutorials before continue…

First: if (health=5) is incorrent for so many things

its not =. it must be == because is a comparation

Second, health is a text component, not a string, not a integrer so can not be equal to any number or text

Third: I understand wht are you trying, but even you solve all the porblems i told, it will be sending the function Play every frame the health is exatcly 5, every frme (this mesn line 10 times a second…) and never when is 4 or 3…

Please. Stop, take your time, bgo back to tutorials and then restart again.

Bye.