Entity names

This is probably a “simple” question to ask, but I am pretty much stuck on this. I am trying to get the names of these entities, I do not want to set them manually so that if I add more stuff later I don’t have to edit the code and add them in.


It prints for example npc_combine_s and I want it to print Combine or something like that, I would like to do this with weapon entities aswell, Cheers.

Edit: no I am not just trying to print the name of it, its for something I don’t feel like releasing just yet.

 if ent:GetClass() == "npc_combine_s" then 


its not but thanks for replying, I don’t want to set them all manually because if I decide later on to add more npcs or other weapons things like that, I would have to go back and edit them all in.

Could you explain more?

I would like to get the entity names as in Combine for npc_combine_s or Deagle for cw_deagle, but if I set all the entity names by hand if I added anything I would have to add it to the pile of names, what I am trying to get is the name from the entity, like the ones in the spawn menu i have already tried


but it comes up as blank space.

Entity.GetName is used to get the hammer name for an entity, i.e. the name given to a map prop when the map was created.

Try using Entity.PrintName or Entity.SpawnName, not sure which one

Both come up as errors:

attempt to call field 'PrintName' (a nil value) 
attempt to call field 'SpawnName' (a nil value)

Tables makes this easy.
local names =
[“npc_combine_s”] = “Combine”

Or if you just want the default name.

Language is popping up as a nil value but i will work with the table for now, Thanks.