Table doesn't load into client - attempt to index a nil value

I get this error appearing whenever I look at a door.

Line 9 of the doorhud.lua is part of an if statement.


elseif(PROPERTIES[eyeTrace.Entity:GetNWInt("PropertyID")].name == nil)then

The PropertyID NWInt is set by the server upon gamemode load, and is available to me when I run a lua_run_cl command on the client. The PROPERTIES table is loaded when the gamemode loads. Here is the first entry into the table. The rest follow the same format, and give no error when defined.



PROPERTIES = {}
PROPERTIES[1] = {
    name = "Evocity Car Dealership",
    doorids = {3472, 3471, 3475, 3476},
    buyable = false,
}


At the bottom of the file is the loading script for the NWInts to be set by the server.


if SERVER then
  timer.Simple(5, function()
      for n, p in pairs(PROPERTIES) do
        for k, v in pairs(p.doorids) do
            for a, e in pairs(ents.GetAll())do
              if(e:MapCreationID() == v)then
                e:SetNWInt("PropertyID", n)
              end
            end
          end
      end
  end)
end


Any ideas?

the reason why is because you’re saying to say a networkint as only server, im assuming, try just having the timer in shared?

It’s giving you the error because you’re trying to index the value within the “PROPERTIES” table, which is nil.

EDIT: My guess would be you don’t have all the entries in the table defined on both the server and client, or you’re aiming at an entity that doesn’t have “PropertyID” set.