Determining Entity Owner?

I’m making an entity for DarkRP, and in it’s init.lua I’m trying to design it so that only the entity’s owner can press E on it.

Here’s what I have.

[lua]function ENT:Use(activator,caller)

if self.dt.owning_ent then

activator:AddMoney(1000)
GAMEMODE:Notify(activator, 1, 4, "You have recieved $"..rand.." for re-selling your stove .")
self:Remove()

else
		
	GAMEMODE:Notify(activator, 1, 4, "Only "..self.dt.owning_ent.." can pick this up.")

end [/lua]

Any help is appreciated, thank you!

You get the owner (if set) in another way in DarkRP now.
This might be helpful: https://github.com/FPtje/DarkRP/commit/8c47aacf010e8e29f4af61b0e32f27297dff0e2f

self:Getowning_ent()

if self:GetOwner() == activator then

If your using self:SetOwner(PLAYER)

otherwise.

self.OwnedBy = PLAYER

if self.OwnedBy and self.OwnedBy == activator then

Well, in your code you are checking if owner exists, instead of checking if hes the one using the entity.
Try repleacing that part on line 3 with [lua]if IsValid(self.dt.owning_ent) and self.dt.owning_ent == activator then[/lua]