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

What can i use _G for?

I need help on this. can anyone help?

1 answer

✓ Accepted answer

You can use _G. for global (Hence the G.) variables, which can be accessed throughout your game. So say I had one script that read below;

_G.Tag = "Hello Digital"

and another script that read;

print(_G.Tag)

Then the variable would be read through the game and the print function would print Hello Digital.

4 comments

0

Two points to mention are nested Tables, and the fact that functions are technically variables in Lua, and thus can be added to Tables.

0

Ummm... You can explain that because I hardly understood that...

0

Also there is a separate _G table for server-side and client-side scripts.

1

@duckwit; Each client gets its own _G for LocalScripts. It's not shared between clients.

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