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

Security with _G variables?

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
2
Answered by
crywink 419 Moderation Voter
5 years ago
Edited 5 years ago

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. :)

1
imagine cry wink BlackOrange3343 2676 — 5y
0
imagine black orange crywink 419 — 5y
Ad
Log in to vote
1
Answered by
ArtBlart 533 Moderation Voter
5 years ago

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.

Answer this question