Global Table, not working with shared.lua?

I currently have a global table(defined in init.lua)


ExampleTable = {}


ExampleTable.Example = {1, 2, 3}

Then Shared.lua:

function GetExample()
return ExampleTable.Example

Current Error:

TestRP\gamemode\shared.lua:26: attempt to index global 'ExampleTable' (a nil value)

*Note: Yes I am trying to send a table with that function.

ExampleInfo and Shared are both defined in Init.lua using include()

i had the same problem, all i did was clear the table, so where you have ExampleTable = {} put below it
ExampleTable.Example = {}

But, I have things AFTER ExampleTable.Example inside the ExampleInfo.lua which is what I am really trying to get…

so its like

Inside of ExampleInfo.lua

ExampleTable.Example = {}
ExampleTable.Example.ExampleTwo = {1,2,3}

No, the problem is that you’re defining the table server-side and trying to call it in a shared function. It will only call it if the shared function is called server-side because you did not make the table client-side. If you want the table to be both client and server side you will have to update it on the client with usermessages and what-not.

Spring = {};
Spring.Item = {}
Spring.Item.Food = {}
Spring.Item.Drink = {}

is what i had to do

What If i made ExampleInfo.lua Server-side AND Client-side?


So are you saying like…

Create a console command that calls the function for the table?


If I chose this method, can I still assign values in the ExampleInfo.lua?

Table made serverside is only accessible serverside unless you send it to the client.

Table made clientside is only accessible clientside unless you send it to the server.

Table made in a shared file is accessible by both. Common sense dude.