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

Is it practical to use _G. variables in this specific use case? [Solved by a comment]

Asked by 5 years ago
Edited 5 years ago

Hello everyone!

So, I am making a plugin for Adonis which grabs a bunch of data from the Adonis API, and places it into a complex table in _G.PTP (server side).

The thing is, the plugin MUST be a module script so Adonis can use it, and the script hides in nil as soon as the game starts. I also have another script that detects changes on the characters of players in game (also server side), and compares it with the values inside of said table, and may occasionally set a value of the table to nil.

However, other scripts such as teleport buttons also need to write to the table when somebody teleports, and there are a lot of said scripts.

Is it practical to use a global table for this? Are there better alternatives? It does not matter if any other server script has access to the table, I just want to know if this method is reliable enough for data transfer with a maximum delay of 5 seconds.

Thank you!

1
You should not use _G. Use module scripts or bindable event/function User#19524 175 — 5y
0
yes greatneil80 2647 — 5y
0
The other script, the one that reads the data from the characters cannot be a module script. LisaF854 93 — 5y
0
Also, what are the advantages of using a module script/bindable event or function over using _G. ? How am I supposed to store the data in a table using a module script or a bindable function/event? LisaF854 93 — 5y
View all comments (2 more)
1
There's nothing wrong with using _G. It's a global variable that references the same table in the machine's memory every time. Having a module return a table will yield the exact same result -- a reference to a table. ozzyDrive 670 — 5y
0
Thank you, this is the kind of answer I was looking for. :D LisaF854 93 — 5y

Answer this question