Spawned Prop has ownder but doesn't send message back that owner killed player

I am currently making a prop launcher (the start of all developers) and I am wondering why, in TTT, the player who launched the prop doesn’t get credit for the crush kill?
When I print out the owner of the melon I get the player who fired it
Relevant Weapon code:


function SWEP:FireMelon(src, ang, vel, angimp, ply)

   local gren = ents.Create("ttt_melonnade_proj")
   if not IsValid(gren) then return end

   gren:SetPos(src)
   gren:SetAngles(ang)

   --   gren:SetVelocity(vel)
   gren:SetOwner(ply)

   gren:SetGravity(0.4)
   gren:SetFriction(0.2)
   gren:SetElasticity(0.45)

   gren:Spawn()
   gren:PhysWake()

   gren:SetOwner(ply)
   
   local phys = gren:GetPhysicsObject()
   if IsValid(phys) then
      phys:SetVelocity(vel)
      phys:AddAngleVelocity(angimp)
   end

   return gren

end

and here is the Melon initialization script if it’s relevant


function ENT:Initialize()
   self:SetModel(self.Model)
   self:PhysicsInit(SOLID_VPHYSICS)
   self:SetMoveType(MOVETYPE_VPHYSICS)
   self:SetSolid(SOLID_BBOX)
   self:SetCollisionGroup(COLLISION_GROUP_PROJECTILE)
   self:GetPhysicsObject():SetMass(50)
end

Just because the Melon is owned by the player, doesn’t mean the kill goes to the player.
If I own a table, and you fall on it and die, I didn’t kill you did I?

You need to set the killer (By getting the owner ofc)

How would I go about doing that? I am looking through the Gmod Wiki and am not finding anything that returns damage data

Try gren:SetPhysicsAttacker(ply)

Looks like that didnt work, I put it after the setowner line :confused:

EDIT: I got it to work! What I did is a used a dmgInfo, the proper way, looks like lua doesn’t let shortcuts :stuck_out_tongue:

Heres the code for any forecomers
–I put it in with my melon_proj code




function ENT:StartTouch( ent )
	if ent:IsPlayer( ) and ent != self.attacker then --only damage someone other than the shooter
		--Make sure to not damage a player twice in the same collision
		ent.lastDamages = ent.lastDamage or {}
		if CurTime( ) > ( ent.lastDamages[self] or 0 ) + 0.5 then
			ent.lastDamages[self] = CurTime( )
		end
		
		local dmgInfo = DamageInfo( )
		dmgInfo:SetDamage( 100 )
		dmgInfo:SetDamageType( DMG_GENERIC )
		dmgInfo:SetAttacker( self.attacker )
		dmgInfo:SetInflictor( self.attacker:GetActiveWeapon( ) )
		dmgInfo:SetDamageForce( Vector( 0, 0, 0 ) )
		ent:TakeDamageInfo( dmgInfo )
	end
end



I’ll have to make SetDamage change with velocity, but thats the basics

EDIT 5(I think…): Anyone with allot of experience have anything on obtaining all entity properties? It seems like the GMOD Wiki is a bit barebones when it comes to that, for now I’m taking apart other mods and seeing what makes them tick
EDIT 99: Okei, turns out that dmginfo takes into account for melon velocity, all is good