Passing int values

Hi everybody. I have this code that goes something like this (abv versions but all the important stuff is in there)

var playerAtt; //player attacking damage
//some other stuff

//thypes of attack functionsfunction Slash()
function Atk1()
{
		//dice roll to see if attack hits
		dice = UnityEngine.Random.Range(1,50); 
		//playerAtt used for attack
		playerAtt = slash * dice;
		print("Slash");
		print(playerAtt);
		return playerAtt;
	
	
}

Ok so this is in one js file for the main character Now I have a second js script to handel input and other items that goes like this;

//this works
//this choses the type of attack and see if player can attack
//also handles input for player
function InputPlayer()
{
	
	var attack = GameObject.Find(player1);
	var bar = GameObject.Find(player1); //ignore this line
	
	if(Input.GetKeyDown(KeyCode.X)) //slash attack
	{
		if(atBar.pixelInset.xMax == 150) {//see if atbar is full
		attack.GetComponent(player1).Atk1(); 
		bar.GetComponent(player1).AttBar();
		}else (print("Cant Attakc"));
	}

ok so far so good. All of this works fine and everything is returning as it should. Here is the problme. I have a enemy
that has some health and when I hit the attack button I want the damage from the variable playerAtt to subtrack from the enemy health. But I cant seam to get the int value from playeratt. How can I access the vaule from the first js script?
Thanks for any help here.

How I’d do that (and I’m probably not THE most skilled programmer) is to find the gameObject of your enemy somehow, e.g. using gameObject.FindWithTag or finding the gameObject that is colliding with your character. Once you have that game object you can use the SendMessage function to call a function in the enemy gameObject that removes health. Is that what you were looking for?

There is acutally no collision it is a rpg game, I will try the send Message function I did not think of that thanks

I got it to work and heres how.
you have to declare at the top of the js code two variables
var ninja : Ninja; //enemy bot
var mav : Mavrick;

then you can link them to the according js code which they represent.
This way you can access the variables using the dot opperator
mav.hp
ninja.hp
ect…