Getting the owner of an entity

Hello, i am trying to show the name of the player who own’s a printer but it is only showing the client’s name. I know i explained this poorly but here is what i mean:

It shows your own name instead of who actually owns the printer

EG: If my name was Joe, and Bob owned the printer. Even if he purchased the printer Joe would show on my screen and Bob would show on their screen. Make sense now?
Good :slight_smile:

I am pretty sure it is because owner = LocalPlayer() but cannot figure out a work-around to show the actual owner of the entity’s name

Here is my draw function:


function ENT:Draw()

	self:DrawModel()

	local pos = self:GetPos()
	local ang = self:GetAngles()
	local owner = LocalPlayer()
	owner = (IsValid(owner) && owner:Nick()) or "Unknown"

	ang:RotateAroundAxis(ang:Up(), 90)
	ang:RotateAroundAxis(ang:Forward(), 90)

	cam.Start3D2D(pos+ang:Up()*7.2, ang, 0.1)
	draw.SimpleTextOutlined(GAMEMODE.Config.currency ..self:GetMoneyStored(),"MoneyFont",0,0,Color(255,255,255),1,1,2,Color(0,0,0))
	cam.End3D2D()

	ang:RotateAroundAxis(ang:Forward(),-90)
	cam.Start3D2D(pos+ang:Up()*3.1, ang, 0.1)
	draw.SimpleTextOutlined("Bronze Printer","PrinterFont",0,0-40,Color(255,255,255),1,1,2,Color(0,0,0))
	draw.SimpleTextOutlined(owner,"ownerFont",0,0,Color(255,255,255),1,1,2,Color(0,0,0))
	cam.End3D2D()

end

Why don’t you use Entity:SetOwner then use Entity:GetOwner so it’s gonna be


local owner = self:GetOwner()

So:


self:SetOwner(LocalPlayer())

then


local owner = self:GetOwner()

?

You gotta use Entity:SetOwner() in the server side code.

Then any idea how i would get the player’s Nick()?


self:GetOwner():Nick()

I hope nothing wrong.

Now it shows the person who is gravgunning the entity

Post your server side code.