Player / Clientside.

Hello Facepunch,

I’m wondering if someone could tell me if the method I want to use is the right way to approach. I’m wanting to make a script where when you’re looking at a player you’ll see an icon above their head, but if you’re not then you’ll not see a icon.

Doing this, would sending a netmessage with a boolean, that boolean with represent true or false, true i you’re looking at someone, false if you’re not. If you’re not it won’t draw, if you are it’ll draw the image.

The only issue is, if i’m using HUDPaint, because that’s always looping every frame, how can i stop this when the player is not looking? ( stop drawing the icon when I’m not looking at someone. )

ThankS, I’ll apprecaite all yea help :slight_smile:

Never use a net message like that. Not only would you be sending tons of messages, but the client already knows when it’s looking at someone.

Use

Player:GetEyeTraceNoCursor

Could you explain a little more please, how does the client know this?

That function shoots an invisible line straight where the player is looking at and returns info on if/what it hit. Take a look at the TraceResult Structure on the function’s page. You can check the entity that was hit by the trace.

Yeah! So I can check if it is a player then just put above his head an icon, but what if I’m not looking at him, how would I not show the icon? ;o

By not showing the icon. The icon isn’t just going to appear over everyone’s heads. The only time the icon will be drawn is when you tell it to.

Would you mind if I add you on Steam for guidance?

There’s no need, my friend. If you need guidance, FP is there for you.