Entity:SetOwner

I’m trying to make it so when entities are automatically spawned by world using a player command it will automatically give the player ownership of the entity.
In the entity spawn I have item:SetOwner(ply) but all that happens is it makes the entity not usable and you can walk through it and the entity is still owned by world.


for k,v in pairs(DarkRPEntities) do	local function buythis(ply, args)
		if ply:isArrested() then return "" end
		if type(v.allowed) == "table" and not table.HasValue(v.allowed, ply:Team()) then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.incorrect_job, v.cmd))
			return ""
		end
		local cmdname = string.gsub(v.ent, " ", "_")


		if v.customCheck and not v.customCheck(ply) then
			GAMEMODE:Notify(ply, 1, 4, "You're not allowed to purchase this item")
			return ""
		end


		local max = tonumber(v.max or 3)


		if ply["max"..cmdname] and tonumber(ply["max"..cmdname]) >= tonumber(max) then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.limit, v.cmd))
			return ""
		end


		if not ply:CanAfford(v.price) then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, v.cmd))
			return ""
		end
		ply:AddMoney(-v.price)


		local trace = {}
		trace.start = ply:EyePos()
		trace.endpos = trace.start + ply:GetAimVector() * 85
		trace.filter = ply


		local tr = util.TraceLine(trace)


		local item = ents.Create(v.ent)
		item.dt = item.dt or {}
		item.dt.owning_ent = ply
		item:SetPos(tr.HitPos)
		item.SID = ply.SID
		item.onlyremover = true
		item:SetOwner(ply)
		item:Spawn()
		GAMEMODE:Notify(ply, 0, 4, string.format(LANGUAGE.you_bought_x, v.name, CUR..v.price))
		if not ply["max"..cmdname] then
			ply["max"..cmdname] = 0
		end
		ply["max"..cmdname] = ply["max"..cmdname] + 1
		return ""
	end
	AddChatCommand(v.cmd, buythis)
end

(Yes DarkRP, don’t bitch, it’s not going to be like most DarkRPs.)

Replace


item:SetOwner(ply)

with


item.Owner = ply

, if you are using FPP.

Tell me, if you are using a different form of prop protection, and I’ll tell you what to replace it with.