vgui Library not working? (Menu not appearing when pressing f2)

Checked other gamemodes for reference, so I’m pretty sure this should work. This IS in cl_init.

[lua]
function teammenu()
tframe = vgui.Create(“DFrame”)
tframe:SetPos(ScrW()0.5, ScrH0.5)
tframe:SetSize(ScrW()0.5, ScrH0.5)
tframe:SetTitle(“Team Selection”)
tframe:SetVisible(true)
tframe:SetDraggable(false)
tframe:ShowCloseButton(true)
tframe:MakePopup()
end
hook.Add(“ShowTeam”, “Team select menu”, teammenu)
[/lua]

“[ERROR] gamemodes/sovarms/gamemode/cl_init.lua:10: attempt to index global ‘vgui’ (a nil value)”

Anyone else had this problem?

VGUI is clientside, and ShowTeam is a serverside hook, I believe.

If not, maybe you overwrote vgui somewhere. Who knows?

What clientside hook could I use then? I’m kind of stumped in that regard.

Untested but should work, put this in a shared file
[lua]
if SERVER then
AddCSLuaFile()

hook.Add("ShowTeam", "TeamSelect", function(ply)
	ply:ConCommand("teamselect")
	end)

else
function teammenu()
tframe = vgui.Create(“DFrame”)
tframe:SetPos(ScrW()0.5, ScrH0.5)
tframe:SetSize(ScrW()0.5, ScrH0.5)
tframe:SetTitle(“Team Selection”)
tframe:SetVisible(true)
tframe:SetDraggable(false)
tframe:ShowCloseButton(true)
tframe:MakePopup()
end

concommand.Add("teamselect", teammenu)

end
[/lua]

If that is in cl_init.lua… how did you get a server-side hook to run? Are you including cl_init.lua in init.lua?

I’m not, and now, it doesn’t display anything when I press f2, including the error. It seems to be disregarding the entire function now, though I set it back to how it was initially :\