GUIText won't update from prefab


I write a game where I have to do something like scoring. I have created a GUIText Object in the hierarchy and a prefab of it in the project. I have a script that executes some kind of code on a triggered event, where I 'd like to update the guiText’s text content. Well I have a variable called score inside that script which is assigned like this :

var score : GameObject;

In the inspector, I have drag n dropped my score prefab to this variable (I did this on another prefab, where I had previously connected with my script, that I have that triggers a particular event). So when I do the following

score.guiText.text = "My New Text";

The GUIText won’t update on the screen. Any ideas?

It seems like your over complicating your scoring system. If your looking to make a player score on the scream using the GUI i would just use a Label and have basic variables. e.g.

var playerScore : int = 0; // playerScore is your score var

function OnGUI() {

GUI.Label ( Rect ( 10, 30, 100, 50 // this is the possition on screena nd size ) "//enter text here like Score: " + playerScore) // this part adds the playerScore tot he label

or somthing similar to this, sorry if this isent what you asked, but i think the way your trying to make the score system is way to hard.

if you want the rest of the script for scoring it in javascript just leave a reply :slight_smile: