Text head

How to make that over the head of the player there was a text?
And how to me then to move away him?

The DrawHUD hook, player:GetPos(), vector:To Screen(), draw.DrawText()

Here you go, however please note that this is part of the RealisticRoleplay’s Roleplay Engine, so you can take idea on this code but do not copy/paste that, it’s useless (you’ll never understand what it does, and it would not be clear by the way you’ll be using someone’s else work.

hook.Add("HUDPaint", "RealisticRoleplay_HoveringNames", function ()
	for _, target in pairs(player.GetAll()) do
		if target:Alive() then	
			local dist = target:GetPos():Distance(LocalPlayer():GetPos())
			if (dist > 350) then continue end
			local targetPos = target:GetPos() + Vector(0,0,84)
			local targetDistance = math.floor((LocalPlayer():GetPos():Distance( targetPos ))/40)
			local targetScreenpos = targetPos:ToScreen()
			draw.SimpleText("TextToDrawHere", "DermaDefault_OR_Whatever_font_name_you_want", tonumber(targetScreenpos.x), tonumber(targetScreenpos.y), Color(200,25,25,200), TEXT_ALIGN_CENTER)			

Found this after looking around for a few seconds. Not sure if it’s helpful or not.

If you want the text to always appear, you can use PostPlayerDraw. If you want it to appear when the client is looking at the player, use the Target ID hook.

For proper scaling, as James xX says… local _x, _y = _p:GetPos( ):ToScreen( ); will give you the proper x and y positions for your screen. You can use the surface / draw library with the ToScreen x and y and it’ll properly scale as you move closer / further away… This will clip through walls,

Alternatively you could use cam.Start 2D / 3D but with this you’d need to manage the angle ( easily managed to face the local player by using the local player angles and adding 180 to yaw )… This will not clip through walls.