Add frags to owner of entity on remove

How can i add Frags with AddFrags() to the owner of a Entity if the Entity gets removed?

I used the serach function first but i didnt find anything D: then add the frags

If i do that i cant spawn the entity D:

If you mean for any entity, it would be like this:

[lua]function GiveFrags(ent)

Bear in mind, when you spawn an entity, SetOwner is not called on the entity. You have to manually set up a system of ownership.