How do I make so I get my entity's printname clientside?

Hello there,

In my entity’s Use function, I’ve made so it adds text to the user’s chat (chat.AddText()).
It says “Hello -username-. You just pressed your USE button on “-my entity’s printname-””.
Thing is I don’t know how I can get my entity’s printname clientside because doing “LocalPlayer():GetEyeTrace().Entity.PrintName” is breaking if I don’t look at the entity but near it since the use function is working a bit near the entity’s “hitbox”.
Is there any way to do that?

Thanks.

You know, you can always test the variables.



local tr = LocalPlayer():GetEyeTrace()
if ( !IsValid(tr.Entity) ) then return end
if ( !tr.Entity.PrintName ) then return end

PrintName is only available to Lua created entities.

self.PrintName in the Use function.