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

Security with _G variables?

I literally only just found out that _G variables are a thing. But there is one concern, how secure are _G variables and what are the pros and cons?

2 answers

✓ Accepted answer

Hey.

Your answer put shortly; nothing is secure on the client whatsoever. Any value on the client can be spoofed in any way shape or form that an exploiter would like. This does include _G as exploiters can access the roblox environment. Exploiters can also go as far as to even modify local variables in your scripts, modify function upvalues, etc...

Accessing your _G is pretty much as simple as getrenv()._G and we're done.

Hope this helped! If it did, please make sure to upvote and accept the answer. :)

2 comments

1

imagine cry wink

0

imagine black orange

In short, _G variables share the same execution context level over all scripts. For example,you can do something like this:

LocalScript

_G.hi = "Hi"
print(_G.hi)

Output: "Hi"

But, if you set the _G variable on the server, the client will not be able to access those variables.

To sum things up, on the server _G is fairly secure because only server scripts can access/change them. However on the client, _G is not secure, as anyone running an exploit can quite easily modify the variables you're using.

Moving onto pros and cons. As for some basic pros you could say:

Variable shared across all scripts of the same context level Easy way to give other scripts access to things like functions, tables and variables

And quite a simple con is:

Not secure on the client whatsoever.

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