Simple SWEP issue

When I shoot something with my SWEP it doesn’t say that I killed it, but the entity

What’s wrong with my SWEP script?


if ( SERVER ) then

AddCSLuaFile( "shared.lua" )

end

if ( CLIENT ) then

	SWEP.PrintName			= "AK 47"			
	SWEP.Author			= "BillyBonker"
	SWEP.Slot			= 1
	SWEP.SlotPos			= 0
	SWEP.IconLetter			= "b"
	
	killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
	
end

SWEP.Base				=	"weapon_base"
SWEP.Instructions			=	"pew pew allahu snackbar"

SWEP.ViewModel				=	"models/weapons/v_rif_ak47.mdl"
SWEP.ViewModelFlip			=	false
SWEP.UseHands				=	true
SWEP.WorldModel				=	"models/weapons/w_rif_ak47.mdl"
SWEP.SetHoldType			=	"ar2"

SWEP.Weight				=	5
SWEP.AutoSwitchTo			=	true
SWEP.AutoSwitchFrom			=	false

SWEP.DrawAmmo				=	false
SWEP.DrawCrosshair			=	true

SWEP.Spawnable				=	true
SWEP.AdminSpawnable			=	true

SWEP.Primary.ClipSize          	=	30
SWEP.Primary.DefaultClip	        =      30
SWEP.Primary.Ammo			=	"smg"
SWEP.Primary.Automatic		=	true
SWEP.Primary.Damage			=	12
SWEP.Primary.NumShots		=	1
SWEP.Primary.Spread			=	0.015
SWEP.Primary.Cone			=	0.015
SWEP.Primary.Delay			=	0.1
SWEP.Primary.Force 			= 	0.5

SWEP.Secondary.ClipSize		=	-1
SWEP.Secondary.DefaultClip	=	-1
SWEP.Secondary.Ammo		=	"none"
SWEP.Secondary.Automatic	=	false

SWEP.ShouldDropOnDie		=	false

local ShootSound = Sound( "Weapon_357.Single" )

function SWEP:Initialize()
	
	self:SetHoldType( "ar2" )
	
end

function SWEP:PrimaryAttack()

	if( not self:CanPrimaryAttack() ) then
		return
	end
	
	local ply = self:GetOwner()
	
	ply:LagCompensation( true )
	
	local Bullet = {}
		Bullet.Num		=	self.Primary.NumShots
		Bullet.Src		=	ply:GetShootPos()
		Bullet.Dir		=	ply:GetAimVector()
		Bullet.Spread	=	Vector( self.Primary.Spread, self.Primary.Spread, 0 )
		Bullet.Tracer	=	0
		Bullet.Damage	=	self.Primary.Damage
		Bullet.AmmoType	=	self.Primary.Ammo
		Bullet.Force	=	self.Primary.Force
		
	self:FireBullets( Bullet )
	self:ShootEffects()
	
	self:EmitSound( ShootSound )
	self.BaseClass.ShootEffects( self )
	self:TakePrimaryAmmo ( 1 )
	self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	ply:LagCompensation( false )

end

function SWEP:CanSecondaryAttack()

	return false
	
end


function SWEP:Reload()

	self.Weapon:DefaultReload( ACT_VM_RELOAD );

end


function SWEP:ShouldDropOnDie()
	
	return false
	
end

[del]Add [lua]Bullet.Attacker = ply[/lua] to the bullet info.[/del]

[editline]30th August 2016[/editline]

Also as a note, remove the lag compensation stuff, FireBullets already makes use of it internally.

Now that I look at it better, it should be the player firing the bullet, not the weapon.

True, I just had to replace self with ply at


self:FireBullets( Bullet )

Thanks!