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 5 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 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 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 — 5y
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 — 5y
Ad

Answer this question