Hello, I have this issue where if I switch to my weapon, an entity stays on the screen when it should be removed. so the code I am using to solve this is this:
[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.FindByClass("C_BaseFlex"))do
ent:Remove()
end
end
end
end )
[/code]
I am using C_BaseFlex because when I used print( self.GhostEntity:GetClass() ) it returned C_BaseFlex, which I supposed was the class name I am supposed to use.
Sorry, you need to Log In to post a reply to this thread.