trying to read from a table

hey! so i have a table


motd_config = {
server_name = "Server Name",
website = "",
button_color = ""
}

in my shared file. and when i use


 motd_config["server_name"]

in my client side i get attempt to globalize error but when i did it with a for loop it worked? do i have to use a for loop around every function just to get data from my table or am i doing something wrong

i also tryed


 config = {}
config["configstuff"] = {
sarvername = "servername"

}


it worked in for loop but idk how to do it without it

[editline]26th October 2014[/editline]

it could be conflicting with another addon

Try to use PrintTable(motd_config) to see if your table works properly, I never saw this kind of error.

shared


local startmotd_config = {
server_name = "Server Name"
}

client


print(startmotd_config.server_name)

still the global error

[editline]26th October 2014[/editline]

i changed the name from startmotd_config to just startmotd and it prints with no errors but it prints nil

Paste the entire error it’s giving you.


[ERROR] addons/startscreen/lua/autorun/client/screenstart.lua:9: attempt to index global 'startmotd_config' (a nil value)
  1. func - addons/startscreen/lua/autorun/client/screenstart.lua:9
   2. unknown - lua/includes/modules/net.lua:32

this was the error but once i changed the table name it went away. but still prints nill

Where is the shared file is located at? Are you AddCSLuaFile’ing it?

its in autorun. and i know it works because when i print the table using for k,v in pairs(startmotd) it works. but i don’t want to have to do that every time i use the table

Get rid of the “local” there.

i did same error

[editline]26th October 2014[/editline]

this is in lua/autorun does the file name need to be shared

I was told file names mean nothing other than organization, so no.