attempt to index field 'Frame' (a nil value)

Hello,

I’m working on a scoreboard, and it’s all set and ready to go. Only problem is, when i first join, I get this error along with the default sandbox scoreboard:



[ERROR] addons/mw3scoreboard/lua/autorun/client/cl_scoreboard.lua:113: attempt to index field 'Frame' (a nil value)
  1. unknown - addons/mw3scoreboard/lua/autorun/client/cl_scoreboard.lua:113


Here’s where “Frame” is defined:



local mw3scoreboard = {};
mw3scoreboard.Frame = vgui.Create("DFrame");


This is line 113 ( the line right under mw3scoreboard.Frame = … ):



mw3scoreboard.Frame:SetSize(ScrW(), ScrH());


When i re-save the file and go back in game, I no longer get that error and my scoreboard works.

What’s wrong?

Where is that located? When do you try to draw the frame? You might be doing it too early.

addons/mw3scoreboard/lua/autorun/client/cl_scoreboard.lua
It’s vgui just sitting outside all functions, should I be putting it in a timer with 0 or something?

You are including the file in your cl_init, right?

it’s just an addon that has a file in autorun/client.