How to clear a controlspanel ?


I don’t know how I can clear a controlspanel.

Could you help me please ?

Please explain yourself more

I make a controlspanel in the event : **[TOOL.BuildCPanel](**

TOOL.Category = “Pulp MMORPG Tools”
TOOL.Name = “NPC Auto Spawner”
TOOL.Command = nil
TOOL.ConfigName = nil

local selected_npc = nil;

if CLIENT then
language.Add( “Tool_NPCSpawner_name”, “NPC Auto Spawner” )
language.Add( “Tool_NPCSpawner_desc”, “Utiliser pour creer un npc qui reapparait quand il meurt.” );
language.Add( “Tool_NPCSpawner_0”, “Clique-gauche : Faire apparaitre/ajouter un NPC Auto spawner. Clique-droit: Enlever le NPC Auto Spawner.” );

function TOOL:LeftClick( trace )
if(selected_npc == nil and trace.Entity:IsNPC()) then
selected_npc = trace.Entity;

            return true;


function TOOL:RightClick( trace )

function TOOL.BuildCPanel( panel )
if(selected_npc != nil) then
local options = {};
options[“Allie”] = {type_npc = 0};
options[“Ennemi neutre”] = {type_npc = 1};
options[“Ennemi total”] = {type_npc = 2};

            panel:AddControl("ListBox", {
                    Label = "Hostilite",
                    Description = "Type du npc qui apparaitra.",
                    Options = options,
                    MenuButton = 1
            panel:AddControl("Label", {
                    Text = "Veuillez selectionner un npc !"


But the controlspanel isn’t edited when I select a npc…

How I can this ?

[lua]function TOOL:BuildCPanel( panel )[/lua]

instead of

[lua]function TOOL.BuildCPanel( panel ) [/lua]

Also, for gods sake learn english.

Now, it return this error :

[@gamemodes\sandbox\gamemode\spawnmenu\controlpanel.lua:99] ControlPanelBuildFunction Error: [addons estmod\lua\weapons\gmod_tool\stools
pcspawner.lua:40] attempt to index local ‘panel’ (a nil value)

Do you have an idea ?

I know the error but I don’t know how repair it.

Can you help me please ?