Need help setting ownership of a spawned SENT

I am coding a SENT for gmod and in order for it to work properly I need to somehow assign the player spawning the item as the SENT’s owner when it is initially spawned. However I am not sure on how to do this… No matter what I try I can’t seem to get the spawner so I can assign ownership to the SENT. Can anyone offer up suggestions on how I might go about doing this?

Thanks for any help in advanced.

You can use ENTITY:SpawnFunction ( and use:

local ent = ents.Create( self.Classname )
ent:SetOwner( pl )

How does one use the spawn function? Would I call the function from initialization? or is this the default function garrysmod calls when the entity is created?

[lua]function ENT:SpawnFunction( ply, trace, class )
local ent = ents.Create( self.Classname ) // Get the entity that you need to spawn
bronze:SetPos(trace.HitPos.x, trace.HitPos.y, trace.z + 10)) // Set its position
ent:Spawn() // Spawn it
self:SetOwner( ply ) // Then set its owner
A normal SENT SpawnFunction would look like this. This function is called when the client spawns it, if you have it in the SENT Lua file.