Bleeding with % chance of it to happen *solved*

Hey guys! Im new here, so, sorry if i make the post wrong or this is already answered, but i can’t find the solution anywhere. Well… I’m trying to make a game and i want my player to bleed when he got hit by an enemy, but i don’t want it to bleed every time he got hit. I’d like to put a % of chance to bleed, like it has 30% of chance to bleed if he got hit by the enemy. I have one script working, but it start bleeding if the player lose or reach a certain amount of health. This is my script at the momment:

EDIT**.: I’m editing the script because i made some changes (small changes).

var MaxHealth = 15000;
var Health : int;
var BleedThreshold = 11000;
var bleedTime: float = 5.0; //Time till the player starts to Bleed after timer Trigger
var bleedSpeed = 100; //How fast the Player Bleeds

function Start ()
{
	Health = MaxHealth;
}

function Update () 
{
	if(Health <= 0)
	{
		Dead();
	}
}

function ApplyDammage (TheDammage : int)
{
	Health -= TheDammage;
	
}

InvokeRepeating("bleeding", 3, 10);

function bleeding ()
{
	if(Health <= BleedThreshold && Health > -1)
	{
		Health -= bleedSpeed;
	}
}

function Dead()
{
	RespawnMenuV2.playerIsDead = true;
	Debug.Log("Your Player Died");
}

function RespawnStats ()
{
	Health = MaxHealth;
}

I don’t know if i’m right, because i’m new to this, but, i think i need to make another function just for the bleeding action, out of the update function, in order to make it stop in the future, like, if my player use a painkiller item or something like that, it will stop bleeding. Well, i hope you guys can understand and help me. =D Thanks

I would suggest to keep the bleeding function from beign invoked all the time, and check for bleeding only when you get hit. So on your ApplyDamage function at the end you can call the bleeding function, then do the bleeding stuff on Update with a boolean.
As for the bleed chance you can use a random range between 0,100, if the bleeding range is minor of 30 then turn the boolean to true and it will start bleeding on Update.

I’m sorry I don’t knw JScript, so I made you an example in C#, hope you can convert it:

public bool bleed = false;	
public float bleedChance = 30;
	
void bleeding () {
        if(Health <= BleedThreshold && Health > -1)
        {
	float bleedPercentage = Random.Range(0,100);
	if(bleedPercentage < bleedChance)
	      bleed = true;
	 }			
}
	
void Update () {
	if(bleed)
		//Put your bleeding stuff here
}

So if you use something to cure yourself, you just set the bleed bool to false and you are done.