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

What can i use _G for?

Asked by 10 years ago

I need help on this. can anyone help?

1 answer

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

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.

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. adark 5487 — 10y
0
Ummm... You can explain that because I hardly understood that... M39a9am3R 3210 — 10y
0
Also there is a separate _G table for server-side and client-side scripts. duckwit 1404 — 10y
1
@duckwit; Each client gets its own _G for LocalScripts. It's not shared between clients. adark 5487 — 10y
Ad

Answer this question