So recently been working on a little neat and helpful player menu and I've noticed that my derma menus are not initializing when I fist join in the game. I get this error.
[CODE]
[ERROR] lua/autorun/client/cl_menu.lua:7: attempt to index local 'menuFrame' (a nil value)
1. playerMenu - lua/autorun/client/cl_menu.lua:7
2. unknown - lua/autorun/client/cl_menu.lua:18
[/CODE]
Even when I put this into autorun/client with if SERVER then end at the top I still get this exact error.
If I edit the file though it loads in properly once I save it though.
Any ideas?
Please post your code otherwise we cannot help you
[QUOTE=Exploderguy;47643332]Please post your code otherwise we cannot help you[/QUOTE]
[CODE]print ( "Menu Initializing..." )
function playerMenu()
if IsValid(menuFrame) then menuFrame:Remove() end
local menuFrame = vgui.Create( "DFrame" )
menuFrame:SetSize( 1024, 512 )
menuFrame:SetPos(5, 5)
menuFrame:SetTitle( "Menu" )
menuFrame:SetVisible( true )
menuFrame:SetDraggable( false )
menuFrame:SetBackgroundBlur( true )
menuFrame:ShowCloseButton ( true )
menuFrame:MakePopup()
menuFrame:Center()
local menuPanel = vgui.Create( "DPanel", menuFrame)
menuPanel:SetSize( 800, 380 )
menuPanel:SetPos ( 5, 5 )
menuPanel:Center()
end
playerMenu()
print( "Menu Initialized." )[/CODE]
Try removing the IsValid(MenuFrame) line. Somthing might be throwing a false positive
Perhaps you're loading before the DFrame is loaded, try
[lua]
print ( "Menu Initializing..." )
function playerMenu()
if IsValid(menuFrame) then menuFrame:Remove() end
local menuFrame = vgui.Create( "DFrame" )
menuFrame:SetSize( 1024, 512 )
menuFrame:SetPos(5, 5)
menuFrame:SetTitle( "Menu" )
menuFrame:SetVisible( true )
menuFrame:SetDraggable( false )
menuFrame:SetBackgroundBlur( true )
menuFrame:ShowCloseButton ( true )
menuFrame:MakePopup()
menuFrame:Center()
local menuPanel = vgui.Create( "DPanel", menuFrame)
menuPanel:SetSize( 800, 380 )
menuPanel:SetPos ( 5, 5 )
menuPanel:Center()
end
hook.Add( "InitPostEntity", "InitMen", function( )
playerMenu()
print( "Menu Initialized." )
end )
[/lua]
[QUOTE=Kamshak;47646427]Perhaps you're loading before the DFrame is loaded, try
[lua]
print ( "Menu Initializing..." )
function playerMenu()
if IsValid(menuFrame) then menuFrame:Remove() end
local menuFrame = vgui.Create( "DFrame" )
menuFrame:SetSize( 1024, 512 )
menuFrame:SetPos(5, 5)
menuFrame:SetTitle( "Menu" )
menuFrame:SetVisible( true )
menuFrame:SetDraggable( false )
menuFrame:SetBackgroundBlur( true )
menuFrame:ShowCloseButton ( true )
menuFrame:MakePopup()
menuFrame:Center()
local menuPanel = vgui.Create( "DPanel", menuFrame)
menuPanel:SetSize( 800, 380 )
menuPanel:SetPos ( 5, 5 )
menuPanel:Center()
end
hook.Add( "InitPostEntity", "InitMen", function( )
playerMenu()
print( "Menu Initialized." )
end )
[/lua][/QUOTE]
That seem to work. Thank you!
Sorry, you need to Log In to post a reply to this thread.