Best way of solving this issue?

Hello, I have an issue with my server, running f2s stronghold. The video below basically explains it all.

I have attempted at solving it with this:



hook.Add( "KeyPress", "RemoveEntity", function( ply, key )
   if ( ply:GetActiveWeapon():GetClass() == "weapon_sh_tool" ) then
       if(key == KEY_1 or key == KEY_2 or key == KEY_3 or key == KEY_4)then
           for k, ent in pairs( ents.FindByName("GhostEntity"))do
               ent:Remove()
           end
       end
   end
end )


but that seems to have no effect.

Change the entity to C_BaseFlex like you told me… Also, you don’t need to make 20 threads for the same problem; don’t mark the others as solved

my code:



hook.Add( "KeyPress", "RemoveEntity", function( ply, key )
   if ( ply:GetActiveWeapon():GetClass() == "weapon_sh_tool" ) then
       if(key == KEY_1 or key == KEY_2 or key == KEY_3 or key == KEY_4)then
           for k, ent in pairs( ents.FindByName("C_BaseFlex"))do
               ent:Remove()
           end
       end
   end
end )


I still have the issue and the code seems to have no effect at all

this is what my lua file looks like so far: http://185.38.148.82/~moogamin/tool%20gun/weapon_sh_tool/stools/weaponcrate.lua

but it has absolutely no effect

code: (right at the bottom)



hook.Add( "KeyPress", "RemoveEntity", function( ply, key )
             if(key == KEY_1 or key == KEY_2 or key == KEY_3 or key == KEY_4)then
                 self.GhostEntity:Remove()
             end
        end)