Public variables not updating?

I'm trying to show the player's total score at the end of the game, but it seems that it's only displaying the value that I originally declared it as.

For example, here's some psuedo code:

public int score = 1;
score = kills * 50;

No matter how many kills I get, my score is always displayed as 1. How do I fix this?

Edit: I guess it has something to do with the order of my code. I'm accessing the score variable from a separate scene and separate script. How do I make sure everything goes in the right order?


I think you have to use static vars for what you're trying to do.

static var score : int = 1;

you'd access the variable with:

myScriptName.score = 

I'm probably not 100% correct here but I think normal vars (var score : int) are already public, meaning that you can see them in the inspector and access the throughout that script and have them accessible through GetComponent.

As opposed to a private var (private var score : int) that is not visible in the inspector and is only accessible from that script.

Hope it helps!