Owner of entity help?

Hello, how would I go about finding the owner of an entity, as in the player who spawned it? I tried self:GetOwner():GetName() but that didnt seem to work…
Thanks for the help!

I believe you need to set the owner of the prop when it is spawned. GetOwner() returns a null entity because SetOwner() wasn’t called anywhere for the entity the player spawned.

int my Initialization function I put self:SetOwner(LocalPlayer()) and used self:GetOwner() in my ENT:Use function, returns error: attempt to call gloval ‘LocalPlayer’ (a NIL value)

LocalPlayer does not exist in the server realm.

Try something like this

hook.Add("PlayerSpawnedProp","setentowner",function(ply, model, ent) ent:SetOwner(ply) end)

Don’t do this, read below.

Don’t do that, entities won’t collide with player




Thanks for correcting me. I should’ve read the wiki page more carefully.

I’ve done some more research and found this as well.

Hopefully this helps others learning like myself.

Hmm, I will look more into these options. Thank you to everyone who took the time to reply. -Solved.

I used self:GetCreator():GetName() and it seemed to work perfectly, again, thanks guys.