TTT disappear on death

Hello, I’m trying to import CSGO knives into TTT. I noticed that when the player dies in TTT their ragdoll gets removed and I received this error:

I didn’t notice this issue in Sandbox, everything seemed to work fine. After some looking into the core Player files, I still couldn’t figure out why it was doing this.
(Happens with all playermodels)



[ERROR] gamemodes/terrortown/gamemode/player.lua:600: attempt to call method 'DampenDrop' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/player.lua:600
   2. DispatchTraceAttack - [C]:-1
    3. DoAttack - addons/csgo-knives/lua/weapons/csgo_baseknife.lua:151
     4. unknown - addons/csgo-knives/lua/weapons/csgo_baseknife.lua:99


Since this outputs a nil value I assume the player’s ragdoll/the player is getting removed?

Here’s the SWEP base on lines 102-192



function SWEP:DoAttack( Altfire )
    local Weapon    = self.Weapon
    local Attacker  = self:GetOwner()
    local Range     = Altfire and 48 or 64
    local Forward 	= Attacker:GetAimVector()
	local AttackSrc = Attacker:EyePos()
	local AttackEnd = AttackSrc + Forward * Range
    local Act
    local Snd
    local Backstab
    local Damage
    
    Attacker:LagCompensation(true)
    
    local tracedata = {}

	tracedata.start     = AttackSrc
	tracedata.endpos    = AttackEnd
	tracedata.filter    = Attacker
    tracedata.mask      = MASK_SOLID
    tracedata.mins      = Vector( -16 , -16 , -18 )
    tracedata.maxs      = Vector( 16, 16 , 18 )
	
    -- We should calculate trajectory twice. If TraceHull hits entity, then we use second trace, otherwise - first.
    -- It's needed to prevent head-shooting since in CS:GO you cannot headshot with knife
    local tr1 = util.TraceLine( tracedata )
    local tr2 = util.TraceHull( tracedata )
    local tr = IsValid(tr2.Entity) and tr2 or tr1
    
    Attacker:LagCompensation(false) -- Don't forget to disable it!
    
    local DidHit            = tr.Hit and not tr.HitSky
    -- local trHitPos          = tr.HitPos -- Unused
    local HitEntity         = tr.Entity
    local DidHitPlrOrNPC    = HitEntity and ( HitEntity:IsPlayer() or HitEntity:IsNPC() ) and IsValid( HitEntity )
    
    -- Calculate damage and deal hurt if we can
    if DidHit then
        if HitEntity and IsValid( HitEntity ) then
            Backstab = DidHitPlrOrNPC and self:EntityFaceBack( HitEntity ) -- Because we can only backstab creatures
            Damage = ( Altfire and (Backstab and 180 or 65) ) or ( Backstab and 90 ) or ( ( math.random(0,5) == 3 ) and 40 ) or 25
            
            local damageinfo = DamageInfo()
            damageinfo:SetAttacker( Attacker )
            damageinfo:SetInflictor( self )
            damageinfo:SetDamage( Damage )
            damageinfo:SetDamageType( bit.bor( DMG_BULLET , DMG_NEVERGIB ) )
            damageinfo:SetDamageForce( Forward * 1000 )
            damageinfo:SetDamagePosition( AttackEnd )
            HitEntity:DispatchTraceAttack( damageinfo, tr, Forward )
            
        else
            util.Decal("ManhackCut", tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal)
            -- Old bullet's mechanic. Caused an one hilarious bug. Left for history.
            
            --local Dir = ( trHitPos - AttackSrc )
            --local Bulletinfo = {}
            --Bulletinfo.Attacker = Attacker
            --Bulletinfo.Num      = 1
            --Bulletinfo.Damage   = 0 
            --Bulletinfo.Distance = Range
            --Bulletinfo.Force    = 10
            --Bulletinfo.Tracer   = 0
            --Bulletinfo.Dir      = Dir
            --Bulletinfo.Src      = AttackSrc
            --self:FireBullets( Bulletinfo )
        end
    end
    
    --Change next attack time
    local NextAttack = Altfire and 1.0 or DidHit and 0.5 or 0.4
    Weapon:SetNextPrimaryFire( CurTime() + NextAttack )
	Weapon:SetNextSecondaryFire( CurTime() + NextAttack )
    
    --Send animation to attacker
    Attacker:SetAnimation( PLAYER_ATTACK1 )
    
    --Send animation to viewmodel
    Act = DidHit and ( Altfire and ( Backstab and ACT_VM_SWINGHARD or ACT_VM_HITCENTER2 ) or ( Backstab and ACT_VM_SWINGHIT or ACT_VM_HITCENTER) ) or ( Altfire and ACT_VM_MISSCENTER2 or ACT_VM_MISSCENTER)
    if Act then
        Weapon:SendWeaponAnim( Act )
        self:SetIdleTime( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
    end
    
    --Play sound
    Snd = DidHitPlrOrNPC and (Altfire and "csgo_knife.Stab" or "csgo_knife.Hit") or DidHit and "csgo_knife.HitWall" or "csgo_knife.Slash"
    if Snd then Weapon:EmitSound( Snd ) end
    
    return true
end


If anyone knows why this is happening please let me know <3

Answer

You could also derive from the TTTbase