How to use global variables?

Hey guys, I have a server side file where the BankTable is defined, now, I need a way to access it from the client file, even tho the server file gets called first the client seems not to be able to access it?

How do I do this so I could access the table from both clientside and serverside files?
Do I need to redefine the table in each file?

Lua does not magically transfer all your serverside variables to the client automatically, you need to do this yourself.

If it’s a static table (e.g. you’re not gonna change it based on the server variables) then you can just redefine it on the client. To save time and everything you could use a shared file that’s included both on the client and the server which could contain the table so they’re both up to date.

If it’s a table that changes a lot and needs to be sent to the client (or just changed in any way) then you need to send the new information to the player(s), preferably with **[Usermessages

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Usermessages)**.

couldnt you just run the table shared?

Yes but keep in mind that changes wont be synchronized

true

Global variables are just variables that can be accessed from any function running in the same state as that variable. You can’t access a global serverside variable from the client without first streaming that to the client, which has already been gone over in this thread.

But yeah, what you’re wanting is a something that’s broadcasted, and in the future that’s what you should be asking for.