• HUD error
    2 replies, posted
Can someone tell me why I'm getting this error. [CODE][ERROR] addons/rg nlrbox/lua/autorun/client/cl_init.lua:31: function arguments expected near 'end' 1. unknown - addons/rg nlrbox/lua/autorun/client/cl_init.lua:0 [/CODE] Here is the HUD code [CODE]function NLRBox() local NFrame = vgui.Create( "DFrame" ) NFrame:SetPos( 5, 5) NFrame:SetSize( 250, 150) NFrame:SetTitle( "NLR - New Life Rule" ) NFrame:SetVisible( true) NFrame:SetDraggable( false ) NFrame:ShowCloseButton( false ) NFrame:MakePopup() local NPanel = vgui.Create( "DPanel" ) NPanel:SetParent(NFrame) NPanel:SetSize( 230, 130) NPanel:SetPos( 5, 5) local NLable = vgui.Create( "DLabel" ) NLabel:SetParent(NPanel) NLable:SetPos(4, 4) NLabel:SetText( "Oh dear! It seems you have died!" ) NLabel:SetTextColor( Color( 255, 0, 0, 255) ) NLabel:SizeToContents() local NButton = vgui.Create( "DButton" ) NButton:SetParent(NLabel) NButton:SetPos( 5, 5 ) NButton:SetText( "I Understand" ) NButton:SetSize( 180, 30 ) NButton.DoClick = function () NFrame:Close end end concommand.Add("NLR", NLRBox) [/CODE]
[lua]NButton.DoClick = function () NFrame:Close end[/lua] Should be NFrame:Close() Also, you don't have to do panel:SetParent() for all the child panels you want to make. You can set the parent in the vgui.Create: [lua]local panel = vgui.Create( "DButton", base )[/lua] Or you can just panel:Add(): [lua]local panel = base:Add( "DButton" )[/lua]
Thanks! That worked man! [editline]11th January 2014[/editline] [QUOTE=Internet1001;43500400][lua]NButton.DoClick = function () NFrame:Close end[/lua] Should be NFrame:Close() Also, you don't have to do panel:SetParent() for all the child panels you want to make. You can set the parent in the vgui.Create: [lua]local panel = vgui.Create( "DButton", base )[/lua] Or you can just panel:Add(): [lua]local panel = base:Add( "DButton" )[/lua][/QUOTE] I'm farely new to coding lua, thanks for telling me that with the parent situation.
Sorry, you need to Log In to post a reply to this thread.