Spawning an entity using eyetracers

Hello, i’m having issues spawning an ammo box in an appropriate position, here is what i currently have. Is there any way i could spawn it in front of my NPC?


function boughtPistolAmmo(len,activator)

		local pistolAmmo = ents.Create("item_ammo_pistol")
			pistolAmmo:SetPos(activator:GetEyeTrace().HitPos)

	if not activator:canAfford(100) then
		DarkRP.notify(activator,1,4,"You cannot afford this!")
		return ""
	else
	activator:addMoney(-pistolAmmoPrice)
	DarkRP.notify(activator,1,4,"You have bought Pistol Ammo for ".. GAMEMODE.Config.currency .. pistolAmmoPrice)
	pistolAmmo:Spawn()
	end
end
net.Receive("pistolAmmoBought", boughtPistolAmmo)

I think ENTITY:LocalToWorld may be what you are looking for.

Don’t create the entity until player can afford it
For get the position do NPC:GetPos() + NPC:GetForward() * 32 + Vector(0,0,30)

Thanks for the info, i’ll look into it :slight_smile:

[editline]30th July 2017[/editline]

I’ll try this, thanks for the reply :slight_smile: