Are you declaring your variable as a local
?
For example, is the beginning of your function similar to this?:
local gamescore = score;
If so, you'll need to remove the local
, like so:
gamescore = score;
This is because the local
definition only declares variables in the local block of code that it resides (i.e, it cannot be called anywhere else).
For example, if I had this function:
function = Test(score)
local sc = 0+score;
return sc;
end
The variable sc
wouldn't be available anywhere else, apart from inside this function, whilst:
function = Test(score)
sc = 0+score;
return sc;
end
this sc
would, as it is not local
to that specific function.
Don't use local
if you want your variable to be used elsewhere, but be careful that you don't overwrite it in some other function, it's easy to do, as I've done it myself a few times.