Why doesn't this draw any text?

I’m trying to make a player info script that shows a player’s name, health, weapon and so on (regardless of if a player is being looked at or not).
I made this code for testing, but it wont print anything (no errors)

Targ is set to the player i last looked at (tested working, so that’s not it)

function DrawName()
	if Targ:IsValid() then
		SPos = {}
		SPos = Targ:GetPos():ToScreen()
		draw.WordBox(8, SPos.x, SPos.y, "Player","Default",Color(50,50,75,100),Color(255,255,255,255))

What makes the target valid?
and you do realize all this will do is but a word box on your screen saying player thats it.
And no targ is not set to player in this function.
try this.
[lua]function DrawName()
local Targ = LocalPlayer()
if Targ:IsValid() then
SPos = {}
SPos = Targ:GetPos():ToScreen()
draw.WordBox(8, SPos.x, SPos.y, “Player”,“Default”,Color(50,50,75,100),Color(255,255,255,255))
LocalPlayer():ChatPrint(“Invalid”) – If im correct this would print invalid on the player’s chatbox but not the player pointing the player being pointed at
– I would try ply:ChatPrint(“Invalid Target”) and add function DrawName(ply) unless thats what you want it to do

I had the targ part working in another part of the script i said >.>

How would i make the name follow the player on my screen?

Learn to read, he said he had the code, and that Targ is set to a player within another section of his code, he even clearly states “that’s not the problem”. Not to mention I think he knew that it would have only printed the player. Perhaps he just did that for testing purposes before he started doing all of the :GetHealth/Pos/Angles/ etc. People do test code before they write the whole thing and find out they might have done it wrong and have to rewrite it.

matte3560, how exactly are you calling the function? Just the once?

You should be calling it with a HUDPaint hook, so that it is constantly being updated on the client.

Ok, i was calling it in a part of my script that was run on think, that might have been the problem…
i’ll try to call it on hudpaint


That worked, thanks a bunch JSharpe!


One more thing, how can i get the size of the text box? the thing now has it’s upper left corner where the player is. I could adjust it manually, but that would be far from accurate.

What you’re wanting is basically like how a common ESP works;

using these functions if I believe:

and ToScreen which you are already using.

I have not seen or heard of a function to actually get a draw.wordbox’s size. Though could easily be converted to a Derma label where you can, draw/called the same way I think, though have not done much testing myself with it. Entirely your choice.