Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to i plus one to a global variable?

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.

3 comments

0

This is way too confusing, try to put your code in an lua code block, and what is "_G"?

0

Also, can you say what the scripts are? Is one a localscript or an script? Also, format your code.

0

_G is global variable

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.