Help with Cannibal swep ttt

Can someone tell my why this is not working? It is supposed to leave behind a ragdoll when one player uses it to “eat” another but nothing is left and the weapon never removes itself.


-- First some standard GMod stuff
    if SERVER then
    AddCSLuaFile( "shared.lua" )
    end
resource.AddSingleFile("sound/omnom.mp3")
	resource.AddFile("materials/VGUI/ttt/canibal.vmt")
	resource.AddSingleFile("materials/vgui/entities/fists_weapon.vtf")
	resource.AddSingleFile("materials/vgui/entities/fists_weapon.vmt")
	resource.AddSingleFile("models/weapons/v_fists_t.dx80.vtx")
	resource.AddSingleFile("models/weapons/v_fists_t.dx90.vtx")
	resource.AddSingleFile("models/weapons/v_fists_t.mdl")
	resource.AddSingleFile("models/weapons/v_fists_t.sw.vtx")
	resource.AddSingleFile("models/weapons/v_fists_t.vvd")
	resource.AddSingleFile("models/weapons/v_fists_tt.dx90.vtx")
	resource.AddSingleFile("models/weapons/w_fists_t.dx80.vtx")
	resource.AddSingleFile("models/weapons/w_fists_t.dx90.vtx")
	resource.AddSingleFile("models/weapons/w_fists_t.mdl")
	resource.AddSingleFile("models/weapons/w_fists_t.phy")
	resource.AddSingleFile("models/weapons/w_fists_t.sw.vtx")
	resource.AddSingleFile("models/weapons/w_fists_t.vvd")
     
    if CLIENT then
    SWEP.PrintName = "Cannibalism"
    SWEP.Slot      = 7 -- add 1 to get the slot number key
     
    SWEP.ViewModelFOV  = 72
    SWEP.ViewModelFlip = true
    end
     
    -- Always derive from weapon_tttbase.
    SWEP.Base                               = "weapon_tttbase"
     
    --- Standard GMod values
SWEP.AllowDrop = false
     
    SWEP.HoldType                   = "melee"
     
    SWEP.Primary.Delay       = 10
    SWEP.Primary.Recoil      = 0
    SWEP.Primary.Automatic   = false
    SWEP.Primary.Damage      = 0
    SWEP.Primary.Cone        = 0.025
    SWEP.Primary.Ammo        = ""
    SWEP.Primary.ClipSize    = 1
    SWEP.Primary.ClipMax     = 1
    SWEP.Primary.DefaultClip = 1
    SWEP.Primary.Sound       = Sound( "omnom.mp3" )
     
    SWEP.IronSightsPos = Vector( 6.05, -5, 2.4 )
    SWEP.IronSightsAng = Vector( 2.2, -0.1, 0 )
     
SWEP.ViewModel			= "models/weapons/v_fists_t.mdl"
SWEP.WorldModel			= "models/weapons/w_fists_t.mdl"

--test
local function ReplicateBones( victim, ragObj )

	--Loop through each bone
	local numberOfBones = ragObj:GetPhysicsObjectCount()
	for i = 1, numberOfBones - 1 do
		
		local ragBone = ragObj:GetPhysicsObjectNum( i )	--Get the current bone
		
		if IsValid( ragBone ) then	
			
			local vicBonePos, vicBoneAng = victim:GetBonePosition( ragObj:TranslatePhysBoneToBone( i ) )  --get the position of the bone on the player
				
			ragBone:SetPos( vicBonePos) --set the ragdoll bone position to the player bone position
			ragBone:SetAngles( vicBoneAng )
			
			ragBone:SetVelocity( ragObj:GetVelocity() )
			
		end
		
	end
end
     
    function SWEP:ShouldDropOnDie()
            self:Remove()
    end
     
    function SWEP:OnDrop()
    self:Remove()
    end
     
    function SWEP:PrimaryAttack()
            if not self:CanPrimaryAttack() then return end
     
            self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
           
            local tracedata = {}
            tracedata.start = self.Owner:GetShootPos()
            tracedata.endpos = self.Owner:GetShootPos() + (self.Owner:GetAimVector() * 100)
            tracedata.filter = self.Owner
            tracedata.mins = Vector(1,1,1) * -10
            tracedata.maxs = Vector(1,1,1) * 10
            tracedata.mask = MASK_SHOT_HULL
            local tr = util.TraceHull( tracedata )
     
            local ply = self.Owner
     
                    if IsValid(tr.Entity) then
                    if tr.Entity.player_ragdoll then
     
                    timer.Simple(0.1, function()
                    ply:Freeze(true)
                    ply:SetColor(Color(255,0,0,255))
                    end)
              self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
                                           
              timer.Create("GivePlyHealth_"..self.Owner:UniqueID(),0.5,6,function() self.Owner:SetHealth(self.Owner:Health()+7) end)
                                           
                                            timer.Simple(3.1, function()
                                                    if(ply:Alive()) then
                                                            ply:Freeze(false)
                                                            ply:SetColor(Color(255,255,255,255))

--test
							local meat = ents.Create( "prop_ragdoll" )
							meat:SetModel( "models/Humans/Charple01.mdl" )
							meat:SetPos( ent:GetPos() )
							meat:Spawn()
					                meat:SetColor(Color(255,0,0,255))
							meat:SetCollisionGroup( COLLISION_GROUP_WEAPON )
							ReplicateBones( self, meat )
--test
                                                            tr.Entity:Remove()
                                                            self:Remove()
                                                    end
                                            end )
                                    self.Owner:EmitSound("omnom.mp3")
                                           
                                    end
                    end
                                            self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
                                   
    end
     
    --- TTT config values
     
    -- Kind specifies the category this weapon is in. Players can only carry one of
    -- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
    -- Matching SWEP.Slot values: 0      1       2     3      4      6       7        8
    SWEP.Kind = WEAPON_EQUIP2
     
    -- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
    -- be spawned as a random weapon. Of course this AK is special equipment so it won't,
    -- but for the sake of example this is explicitly set to false anyway.
    SWEP.AutoSpawnable = false
     
    -- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
    SWEP.AmmoEnt = ""
     
    -- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
    -- a role is in this table, those players can buy this.
    SWEP.CanBuy = {ROLE_TRAITOR}
     
    -- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
    -- receive this weapon as soon as the round starts. In this case, none.
    SWEP.InLoadoutFor = nil
     
    -- If LimitedStock is true, you can only buy one per round.
    SWEP.LimitedStock = true
     
    -- If AllowDrop is false, players can't manually drop the gun with Q
    SWEP.AllowDrop = true
     
    -- If IsSilent is true, victims will not scream upon death.
    SWEP.IsSilent = false
     
    -- If NoSights is true, the weapon won't have ironsights
    SWEP.NoSights = true
     
    -- Equipment menu information is only needed on the client
    if CLIENT then
    -- Path to the icon material
    SWEP.Icon = "VGUI/ttt/canibal"
     
    -- Text shown in the equip menu
    SWEP.EquipMenuData = {
            type = "Weapon",
            desc = [[CANNIBALISM! 
			GET RID OF EVIDENCE AND GAIN HEALTH!]]
    };
    end

You are removing the target player, that is a horrible thing to do. Player:Kill() him., Also, ReplicateBones( self, meat ), self should be tr.Entity.

Target player is already dead, he is a ragdoll.

Also I had already noticed that with the tr.Entity. You are correct that it had to be fixed but it still does not work.

You should never remove the player, never.

We aren’t we are removing a ragdoll. Just like the flare gun does that comes with the gametype. The player is not removed.

Yeah, sorry, you got me confused there.
So, uh, why are you recreating the ragdoll? Just change its model?

Its name and ttt facts would still be there if we just changed the model.

Okay, put print(“test”)s all around the code and see where exactly it stops.