Need help with "SLAM" weapon for TTT

Could someone help me figure out how to get this to work?
THe SLAM weapon places on the wall like I want it to, and activates itself with the tripwire laser. However for some reason it refuses to blow up when the laser is broken, or crossed. The only way to get it to blow up in this state is to swing a crowbar at it. All im trying to do is make a tripwire bomb is all.


if SERVER then
   AddCSLuaFile( "shared.lua" )
end

SWEP.HoldType			= "slam"

if CLIENT then
   SWEP.PrintName			= "SLAM"
   SWEP.Slot				= 6
   SWEP.EquipMenuData = {

      type  = "item_weapon",
      name  = "C4",
      desc  = "c4_desc"
   };

   SWEP.Icon = "VGUI/ttt/icon_c4"
end

SWEP.Base = "weapon_tttbase"

SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.WeaponID = AMMO_C4

SWEP.ViewModel  = Model("models/weapons/v_slam.mdl")
SWEP.WorldModel = Model("models/weapons/w_slam.mdl")

SWEP.DrawCrosshair      = false
SWEP.ViewModelFlip      = false
SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = true
SWEP.Primary.Ammo       = "none"
SWEP.Primary.Delay = 5.0

SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"
SWEP.Secondary.Delay = 1.0

SWEP.NoSights = true

local throwsound = Sound( "Weapon_SLAM.SatchelThrow" )
	   
function SWEP:PrimaryAttack()
   self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
   self:BombStick()
end

function SWEP:BombStick()
   if SERVER then
      local ply = self.Owner
      if not ValidEntity(ply) then return end

      if self.Planted then return end

      local ignore = {ply, self.Weapon}
      local spos = ply:GetShootPos()
      local epos = spos + ply:GetAimVector() * 80
      local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})

      if tr.HitWorld then
         local turret = ents.Create("npc_tripmine")
         if ValidEntity(turret) then
            turret:PointAtEntity(ply)

            local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, turret)

            if tr_ent.HitWorld then

				   local ang = tr_ent.HitNormal:Angle()
				   ang:RotateAroundAxis(ang:Right(), -90)
				   ang:RotateAroundAxis(ang:Up(), 180)

				   turret:SetPos(tr_ent.HitPos)
				   turret:SetAngles(ang)
				   turret:SetOwner(ply)
				   turret:SetCollisionGroup(COLLISION_GROUP_NONE)
				   turret:Spawn()
				   

				   turret.fingerprints = self.fingerprints
				   
				   local phys = turret:GetPhysicsObject()
				   if ValidEntity(phys) then
					  phys:EnableMotion(false)
				   end

				   

				   self:Remove()

				   self.Planted = true

            end
         end

         ply:SetAnimation( PLAYER_ATTACK1 )         
      end
   end
end

function SWEP:Touch(ent)
	if ent:IsPlayer() or ent:IsNPC() then
		self.Explode = true
	end
end
	
function SWEP:OnRemove()
   if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
      RunConsoleCommand("lastinv")
   end
end

function SWEP:Reload()
   return false
end
		
function SWEP:SecondaryAttack()
		return false end

I believe its the ValidEntity(phy)
TBH, I don’t know how to fix this. If you got it fixed, can I have the code too please? Because I wanna see how I can fix this for my T weapon…

Edit:

at ValidEntity(phy)
change it to IsValid(phy) and see if that works… I made it work for my manhack gun… Not sure if it will work for you though…

BUMP Sorry, anyways I got a code for you :smiley:

[LUA]
if SERVER then
AddCSLuaFile( “shared.lua” )
resource.AddFile(“materials/tripmine/icon_tripwire.vtf”)
resource.AddFile(“materials/tripmine/icon_tripwire.vmt”)
end

SWEP.HoldType                           = "slam"
 
if CLIENT then
 
   SWEP.PrintName    = "SLAM"
   SWEP.Slot         = 6
 
   SWEP.ViewModelFlip = true
   SWEP.ViewModelFOV                    = 64
   
   SWEP.EquipMenuData = {
      type = "item_weapon",
      desc = [[A mine, with a red laser, placeable on walls. 
	  When the red laser is crossed by innocents or 
	  detectives, the mine explodes. Can be shot and
	  destroyed by innocents and detectives.]]
   };
 
   SWEP.Icon = "tripmine/icon_tripwire"
end

SWEP.Base = “weapon_tttbase”

SWEP.ViewModel                          = "models/weapons/v_slam.mdl"   -- Weapon view model
SWEP.WorldModel                         = "models/weapons/w_slam.mdl"   -- Weapon world model
SWEP.FiresUnderwater = false
 
SWEP.Primary.Sound                      = Sound("")             -- Script that calls the primary fire sound
SWEP.Primary.Delay                      = .5                    -- This is in Rounds Per Minute
SWEP.Primary.ClipSize                   = 1             -- Size of a clip
SWEP.Primary.DefaultClip                = 1             -- Bullets you start with
SWEP.Primary.Automatic                  = false         -- Automatic = true; Semi Auto = false
SWEP.Primary.Ammo                       = "slam"
SWEP.LimitedStock = false

SWEP.NoSights = true
 
SWEP.AllowDrop = true
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR}
 
function SWEP:Deploy()
        self:SendWeaponAnim( ACT_SLAM_TRIPMINE_DRAW )
        return true
end
 
function SWEP:SecondaryAttack()
        return false
end    
 
function SWEP:OnRemove()
   if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
      RunConsoleCommand("lastinv")
   end
end

function SWEP:PrimaryAttack()
self:TripMineStick()
self.Weapon:EmitSound( Sound( “Weapon_SLAM.SatchelThrow” ) )
self.Weapon:SetNextPrimaryFire(CurTime()+(self.Primary.Delay))
end

function SWEP:TripMineStick()
if SERVER then
local ply = self.Owner
if not IsValid(ply) then return end

  local ignore = {ply, self.Weapon}
  local spos = ply:GetShootPos()
  local epos = spos + ply:GetAimVector() * 80
  local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})

  if tr.HitWorld then
     local mine = ents.Create("npc_tripmine")
     if IsValid(mine) then

        local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, mine)

        if tr_ent.HitWorld then

           local ang = tr_ent.HitNormal:Angle()
           ang.p = ang.p + 90

           mine:SetPos(tr_ent.HitPos + (tr_ent.HitNormal * 3))
           mine:SetAngles(ang)
           mine:SetOwner(ply)
           mine:Spawn()

                            mine.fingerprints = self.fingerprints
							
                            self:SendWeaponAnim( ACT_SLAM_TRIPMINE_ATTACH )
                           
                            local holdup = self.Owner:GetViewModel():SequenceDuration()
                           
                            timer.Simple(holdup,
                            function()
                            if SERVER then
                                    self:SendWeaponAnim( ACT_SLAM_TRIPMINE_ATTACH2 )
                            end    
                            end)
                                   
                            timer.Simple(holdup + .1,
                            function()
                                    if SERVER then
                                            if self.Owner == nil then return end
                                            if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
                                            --self.Owner:StripWeapon(self.Gun)
                                            --RunConsoleCommand("lastinv")
											self:Remove()
                                            else
                                            self:Deploy()
                                            end
                                    end
                            end)
                   

                           --self:Remove()
                            self.Planted = true
							
self:TakePrimaryAmmo( 1 )
                           
                    end
        end
     end
  end

end

function SWEP:Reload()
return false
end
[/LUA]

if you cant get it working,

add -AG- DeathrowDave on steam, his server got a working SLAM, its called Tripwire tough