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

How to access a table in another script?

Asked by 6 years ago

I'm trying to create an inventory system, and have that player have an inventory while also displaying the inventory in a GUI. I've decided to use a table to store all of the inventory items(I don't think there is any other way) but i'm not sure how to go about getting table items in another script, if it is at all possible. Any suggestions?

0
Module scripts? /shrug Async_io 908 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Ive heard of a global variable. But tables hold the same purpose so... I think the answer may be...

_G.Table = {}

To access your table globaly

_G.Table --Do what you want with it
0
No, _G is the worst way. User#19524 175 — 6y
0
Yeah, I agree with @incapaz. Instead of _G, you can use BindableEvents and BindableFunctions(that is pretty much the closest "replica" to _G but much better) or you can use ModuleScripts saSlol2436 716 — 6y
Ad

Answer this question