Help plz!

I’ve been looking for a fix for the problem that the vgui will not appear when you press F4 for 2 days now, no one seems to know how to fix it, the file is called vgui/PLoadout.lua and is only included in cl_init as include( ‘vgui/PLoadout.lua’ ) which as far as i know is enough. please if you know how to fix this help me the is driving me mad!

[lua]
function PLoadoutPanel()
local aPanel = vgui.Create( “Frame” )
aPanel:SetSize( 800, 500 )
aPanel:SetPos( 100, 100 )
aPanel:SetVisible( true )
aPanel:MakePopup()

local aButton = vgui.Create( “Button”, aPanel )
aButton:SetText( “Accept” )
aButton:SetPos( 650, 450 )
aButton:SetWide( 100 )
function aButton.DoClick()
aPanel:SetVisible( false )
end

end

function KeyPressed (P, KEY_F4)
PLoadoutPanel()
end

hook.Add( “KeyPress”, “KeyPressedHook”, KeyPressed )

[/lua]

There is no errors what so ever in the console or the client, this file and cl_init is being added to CSlua trough init.lua

First, you want a DPanel and a DButton, since you’ure using derma objects.

Also, your KeyPressed hook is weird - the two arguments are player and key. You can’t just say KEY_F4 is the argument – you have to compare the second argument to a key. And even if you set up that right, the KeyPress hook doesn’t work that way. It only works with IN_KEYS.

However, since you’re using F4, there’s a special hook for that. **[Gamemode.ShowSpare2

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.ShowSpare2)**
You’ll need to use usermessages to tell the client what to do on that hook.

Nope still won’t work, i dont think any of the client code is getting ran because i put print inside every function and it didn’t print shit, is there any reason why the client code would not run?

As stated in the wiki, showspare2 = server-side.

This is why he suggested using usermessages. Did you do that yet?

What is user messages? do you mean chat commands

**[Usermessage

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=User_Messages)**

is a ShowSpare2 hook on the server really the best way to go about it? If I want F1-F4 to do something clientside-only like open a Derma menu I just do
[lua]
function Spare2MenuHook(ply, bind, pressed)
if pressed and string.find(bind, “showspare2”) then
SomeFunction()
end
end
hook.Add(“PlayerBindPress”, “Spare2MenuHook”, Spare2MenuHook)
[/lua]