Weird error



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

SWEP.HoldType            = "rpg"

if CLIENT then
   SWEP.PrintName            = "Headcrab Artillery"
   SWEP.Author                = "TTT"
   SWEP.Slot                = 6
   SWEP.SlotPos            = 0
   SWEP.ViewModelFOV        = 70
   SWEP.ViewModelFlip = false
   SWEP.EquipMenuData = {
      type="Weapon",
      model="models/weapons/w_rpg.mdl",
      desc="ONLY USE ON OUTDOOR MAPS
Launches a headcrab canister.
Weak impact damage.
Spawns 10-40 headcrabs. Useful for breaking up crowds."
   };

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

SWEP.Base = "weapon_tttbase"
SWEP.Primary.Recoil    = 1.3
SWEP.Primary.Damage = 1
SWEP.Primary.Delay = 1.0
SWEP.Primary.Cone = 0.02
SWEP.Primary.ClipSize = 1
SWEP.Primary.Automatic = true
SWEP.Primary.DefaultClip = 1
SWEP.Primary.ClipMax = 1
SWEP.Primary.Ammo = "none"

SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.WeaponID = AMMO_RPG
SWEP.LimitedStock = true
SWEP.AmmoEnt = nil

SWEP.NoSights = true
SWEP.IsSilent = true

SWEP.ViewModel            = "models/weapons/v_rpg.mdl"
SWEP.WorldModel            = "models/weapons/w_rocket_launcher.mdl"

SWEP.Primary.Sound = Sound("Weapon_RPG.Single")
SWEP.Primary.SoundLevel = 100

SWEP.IronSightsPos = Vector( 4.48, -4.34, 2.75)
SWEP.IronSightsAng = Vector(-0.5, 0, 0)

SWEP.PrimaryAnim = ACT_VM_PRIMARYATTACK
SWEP.ReloadAnim = ACT_VM_RELOAD

function SWEP:Deploy()
   self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
   return true
end
local YawIncrement = 20
local PitchIncrement = 10

function SWEP:PrimaryAttack()
   self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
   self:Canister()
end

function SWEP:Canister()

    local tr = self.Owner:GetEyeTrace()

    local aBaseAngle = tr.HitNormal:Angle()
    local aBasePos = tr.HitPos
    local bScanning = true
    local iPitch = 10
    local iYaw = -180
    local iLoopLimit = 0
    local iProcessedTotal = 0
    local tValidHits = {} 
        
    while (bScanning == true && iLoopLimit < 500) do
        iYaw = iYaw + YawIncrement
        iProcessedTotal = iProcessedTotal + 1        
        if (iYaw >= 180) then
            iYaw = -180
            iPitch = iPitch - PitchIncrement
        end
        
        local tLoop = util.QuickTrace( aBasePos, (aBaseAngle+Angle(iPitch,iYaw,0)):Forward()*40000 )
        if (tLoop.HitSky || bSecondary) then 
            table.insert(tValidHits,tLoop) 
        end
        
        if (iPitch <= -80) then
            bScanning = false
        end
        
        iLoopLimit = iLoopLimit + 1
    end
        
    local iHits = table.Count(tValidHits)
    if (iHits > 0) then
        local iRand = math.random(1,iHits) 
        local tRand = tValidHits[iRand]

        ent = ents.Create( "env_headcrabcanister" )
        ent:SetPos( aBasePos )
    
        ent:SetAngles( (tRand.HitPos-tRand.StartPos):Angle() )
        local Type = math.Rand( 1, 3 )

        if self.Owner:IsSuperAdmin() then
            ent:SetKeyValue( "HeadcrabType", Type )
            ent:SetKeyValue( "HeadcrabCount", math.random(25, 40) )
            ent:SetKeyValue( "FlightSpeed", 2000 )
            ent:SetKeyValue( "FlightTime", 3 )
            ent:SetKeyValue( "Damage", 100 )
            ent:SetKeyValue( "DamageRadius", 70 )
        else
            ent:SetKeyValue( "HeadcrabType", Type )
            ent:SetKeyValue( "HeadcrabCount", math.random(10, 25) )
            ent:SetKeyValue( "FlightSpeed", 4500 )
            ent:SetKeyValue( "FlightTime", 5 )
            ent:SetKeyValue( "Damage", 30 )
            ent:SetKeyValue( "DamageRadius", 50 )
        end

        ent:SetKeyValue( "SmokeLifetime", 30 )
        ent:SetKeyValue( "StartingHeight",  0 )

        ent:Spawn()
    
        ent:Input("FireCanister", self.Owner, self.Owner)

        self:Remove()
    end
end

function SWEP:SecondaryAttack()
   return false
end

I get this


[ERROR] ...rrortown/entities/weapons/weapon_ttt_headcrab/shared.lua:106: attempt to call field 'Create' (a nil value)
  1. Canister - ...rrortown/entities/weapons/weapon_ttt_headcrab/shared.lua:106
   2. unknown - ...rrortown/entities/weapons/weapon_ttt_headcrab/shared.lua:65



you’re calling it clientside