I am using Javascript.
I have one script attached to the player with a variable that sets it’s health.
Then I have one script attached to another object which gets bigger as you have more health.
But I can’t use the variable outside of the first script. How do I do this?
There are many many ways you could do this.
Perhaps use GetComponent? Either find the player script using something like GameObject.Find or just assing the script in editor. Here’s a tutorial: http://unity3d.com/learn/tutorials/modules/beginner/scripting/getcomponent
Or if you want a really easy way to do it and you have only one player script in the scene you could use a static variable: http://unity3d.com/learn/tutorials/modules/intermediate/scripting/statics. Just don’t tell the cool kids you are using static variables.
Thanks, I used static variables and it works fine!