Can anyone explain how this is nil?

The code below is client-side code, and is in a net.Receive() that is called when the player initially spawns. It’s erroring on the ‘ply.frost.achievs’ line saying field ‘frost’ is nil. I’m confused as it shouldn’t be nil as the if statement before it ensures it isn’t nil. Can anybody help? :pwn:

local ply = LocalPlayer();
local tbl = net.ReadTable();
if not tbl then return end

if not ply.frost then 
    ply.frost = {}

ply.frost.achievs = tbl;

Remove the if not ply.frost and the end.

That would then defeat the purpose of the frost table as it would be reset every time I sync achievements…

I would rather remove them and change ply.frost = {} to ply.frost = ply.frost or {}

Edit: Send the net messages few seconds later or after the client’s InitPostEntity is done. That may fix it.

Doing both of your suggestions fixed it. Thanks!