Script to recive varible from toher script and do something with it

I would like to know hot to access a variable from another script. Also, is it possible to take a variable in another script and assign it to a variable in the current script, like if I had a variable named (health = 50) and I wanted to set this variable to another variable in my script named health1. So that if (health1) changes so dose (health)

EX. Would the following script work, are there any problems with it.

var health1 = gameObject.Find(Player1).GetComponent(health script).health

function Update () {

}

function OnCollisionEnter(Collided : Collision){

if(Collided.gameObject.name == “Wall”)

health-=1;

{

@ninjaboynaru,

Your post comes across as you stating what you want done and demanding that someone here do it for you. I’m not sure if this was your intention, but that’s now how UnityAnswers works. We’re glad to help you, but we’re not going to write your game for you. If that’s what you’re looking for, you can certainly hire someone on the forums.

That being said, people are absolutely right to point you to the Unity API and documentation. If you don’t understand the Unity API, the first thing to do is to learn a bit about it before you try programming a complex script. If you don’t understand the documentation within the reference pages, you may want to take a step back and invest some time in learning to program in JS or C#. There are many, many tutorials out there that walk you through simple programming, introduce variables and data structures, and will give you everything you need to know. When you’ve done that, then you should be able to follow the Unity GUI scripting guide (Unity - Manual: Immediate Mode GUI (IMGUI)) and examples.

Good luck to you!