Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to i plus one to a global variable?

Asked by 3 years ago

in one script i have

_G.valcoin = 0

script.Parent.Text = _G.valcoin

and in another i have

function onTouched(hit) _G.valcoin += 1 end script.Parent.Touched:connect(onTouched)

but it does not seem to add any number to valcoin? please help.

0
This is way too confusing, try to put your code in an lua code block, and what is "_G"? airsoft561 -3 — 3y
0
Also, can you say what the scripts are? Is one a localscript or an script? Also, format your code. airsoft561 -3 — 3y
0
_G is global variable asdfghjk9019 225 — 3y

1 answer

Log in to vote
0
Answered by
karlo_tr10 1233 Moderation Voter
3 years ago

First of all, you should provide code in the Code block, apart from not making function local (recommended) and using :Connect instead of deprecated :connect your problem may be that one script is normal and another one is local (because you set the text of some instance in it) and they don't share same global valuables. Please provide more information on kinds of scripts, errors and put the scripts in the Code block.

Ad

Answer this question