assigning value to guiText

right, I have a guiText named “nvidiaText” with the following script

whenever I pick up something I want it to increase

the player has this script attached to him

however during launch I get "unknown identifier “nvidiaText” - how do I access the GUIText from the player script?

I’ma total noob at this but i think you’re not telling the Script that’s on the player what nvidia is. I think you need to get it from the script that’s attached to the guiText. Something like:

function OnTriggerEnter(collisionInfo : Collider){

var nvdiaText : int = GameObject.Find("YourguiTextobjectname").GetComponent("nameofguitextscript").nvidia;

if(collisionInfo.gameObject.tag == "3dvision"){
nvidiaText.nvidia++;

Destroy(collisionInfo.gameObject);
}

}

That might be hopelessly wrong cos I’m a noob but give it a go eh?

ok I’ll try to simplify it even further. I’ll try to access the Text property of the GUIText called “nvidiaText”

however it says “Text is not a memeber of unityEngine.GameObject”

the Debuglog updates properly once I pick stuff up

Scripts are components not gameobjects, that’s why GameObject.Find().text won’t work

Try

GameObject.Find("nvidiaText").GetComponent(ScriptType).text = 'something'

Assuming the public property of the script you want changing is called ‘text’

And substitute ScriptType with the right value (depending on your language. I use boo, so its just ScriptType, but I think UnityScript might need typeof(ScriptType). Not sure)

Alternatively, you could bind the nvidia script with the player script, using the Unity inspector.

hi! as I said in the above post for the moment I changed it so it’s simpler- I have a GUIText game object called “nvidiaText”

GUIText is a component, not a game object.

The logic is the same. First, find the game object that has the attached GUIText component

obj = GameObject.Find("MyGameObjectName")

then, get the GUIText component:

guitext = obj.GetComponent(GUIText)

then, change the text

guitext.text = "some text"

thanks it workss!!!