What's wrong with this code?

function GM.OpenTribeMenu()
         local GM = GAMEMODE

         if !GM.TribeMenu then GM.TribeMenu = vgui.Create("GMS_TribeMenu") end



Any ideas?

The error is

[ERROR] gamemodes/lmaollma/gamemode/cl_init.lua:2018: attempt to index field ‘TribeMenu’ (a nil value)

  1. unknown - gamemodes/basewars/gamemode/cl_init.lua:2018
  2. unknown - lua/includes/modules/concommand.lua:6

TribeMenu = “”
function GM:OpenTribeMenu()

     if TribeMenu=="" then TribeMenu = vgui.Create("GMS_TribeMenu") end



That will work unless there’s some sort of very explicit reason that you were using GM.
You can have global variables outside of GM, you know.

Even with the original code supplied by OP, the !GM.TribeMenu condition would be evaluated as true and the VGUI panel would be re-created.
Hydreh, try looking into the console again. There’s most likely a white message similar to “Failed to create VGUI component GMS_TribeMenu” - that’d mean “GMS_TribeMenu” isn’t defined.

Problem solved. Thanks Bobble.