tried to buy weapon his role is not permitted to buy

Hello,
i try to add a item which i found on the steam workshop as traitor item in the Gamemode TTT. But everytime i want to buy it in the Traitor Shop i get this error message " tried to buy weapon his role is not permitted to buy"

my shared.lua looks like this:


-----------------------------
--        CONFIG         --
-----------------------------

local BlastTime = 10 --the time that it takes for the snark to explode, in seconds
local BlastRadius = 160
local BlastDamage = 20

-----------------------------
--          CODE            --
-----------------------------
if ( SERVER ) then
	resource.AddFile("materials/vgui/entities/npc_vj_bmsno_snark.vmt")
end

if ( CLIENT ) then
	killicon.AddFont( "weapon_snark", "CSKillIcons", "C", Color( 255, 80, 0, 255 ) )
	
	SWEP.PrintName			= "Snark"
	SWEP.Base = weapon_tttbasegrenade
	SWEP.Kind = WEAPON_EQUIP2
	SWEP.HoldType = "grenade"
	SWEP.CanBuy = { ROLE_TRAITOR }
	SWEP.InLoadoutFor = nil
	SWEP.AutoSpawnable = false
	SWEP.AllowDrop = true 
	SWEP.IsSilent = false 
	SWEP.LimitedStock = false
	SWEP.NoSights = true
	SWEP.Slot				= 4
	SWEP.SlotPos			= 5
	SWEP.DrawAmmo = true
	SWEP.DrawCrosshair = false
	SWEP.ViewModelFOV		= 90
	SWEP.Icon = "VGUI/entities/npc_vj_bmsno_snark.vmt"
	SWEP.EquipMenuData = {
      type = "Weapon",
      desc = "Let's kill those Innocents!"
   };
	
	function SWEP:CustomAmmoDisplay()
		self.AmmoDisplay = self.AmmoDisplay or {}
		self.AmmoDisplay.Draw = true
		self.AmmoDisplay.PrimaryClip 	= self.Weapon:Clip1()
		self.AmmoDisplay.PrimaryAmmo 	= "AlyxGun"
		self.AmmoDisplay.SecondaryAmmo 	= -1
		return self.AmmoDisplay
	end
else
	SWEP.Weight = 5
	SWEP.AutoSwitchTo = false
	SWEP.AutoSwitchFrom = false 
end

SWEP.Spawnable      = false
SWEP.AdminSpawnable  = true

SWEP.Primary.Delay			= 0.9
SWEP.Primary.Recoil			= 1
SWEP.Primary.Damage			= 8
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0

if not snarks then
	snarks = {}
end

SWEP.Primary.ClipSize		= 100
SWEP.Primary.DefaultClip	= 6
SWEP.Primary.Automatic   	= true
SWEP.Primary.Ammo         	= "none"
SWEP.Primary.Delay          = .5
 
--SWEP.Secondary.Delay		= 0.9
--SWEP.Secondary.Recoil		= 0
SWEP.Secondary.Damage		= 0
--SWEP.Secondary.NumShots		= 1
--SWEP.Secondary.Cone			= 0
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic   	= true
SWEP.Secondary.Ammo         = "AlyxGun"

SWEP.ViewModel      = "models/v_squeak.mdl"
SWEP.WorldModel   = ""

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
	draw.SimpleText( "RCM", "SWEPText", x + wide/2, y + tall*0.1, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
	draw.SimpleText( "C", "CSSelectIcons", x + wide*.45, y + tall*.45, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end

for k = 3, 5 do
	util.PrecacheSound("physics/flesh/flesh_impact_bullet" .. k .. ".wav")
end
util.PrecacheSound("snarkgun/blast.wav")
util.PrecacheSound("snarkgun/deploy.wav")
util.PrecacheSound("snarkgun/die.wav")
util.PrecacheSound("snarkgun/hunt1.wav")
util.PrecacheSound("snarkgun/hunt2.wav")
util.PrecacheSound("snarkgun/hunt3.wav")

function SWEP:Think()
	if not snarks[self.Owner] then snarks[self.Owner] = {} return end
	if SERVER then return end
	
	if not rantime then
		rantime = CurTime() + math.random(15, 25)
	end
	
	if CurTime() >= rantime then
		if not self.attacking then
			rantime = nil
			self.Weapon:SendWeaponAnim( ACT_VM_FIDGET )
			timer.Simple( 4, PlayIdle, self )
		end
	end
end

function ResetAnimations( self )
	if not self then return end
	if not self.Owner or not self.Weapon then return end
	if self.Owner:GetActiveWeapon() == self.Weapon and not self.attacking then
		self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
		timer.Simple( 2, PlayIdle, self )
	end
end

function PlayIdle( self )
	if not self then return end
	if not self.Owner or not self.Weapon then return end
	if self.Owner:GetActiveWeapon() == self.Weapon and not self.attacking then
		self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
	end
end

function SnarkThink()
	for a,b in pairs(snarks) do
		for k,v in pairs(snarks[a]) do
			if not k:IsValid() then
				SnarkBlast( a, snarks[a][k].Pos, k )
			elseif (CurTime() - snarks[a][k].start) > BlastTime then
				SnarkBlast( a, snarks[a][k].Pos, k )
			end
			if k:IsValid() and snarks[a][k] then
				snarks[a][k].Pos = k:GetPos()
			end
		end
	end
end
hook.Add("Think", "Snark Think", SnarkThink)

function SnarkAttack( victim, attacker )
	local snark = {}
	for a,b in pairs(snarks) do
		for k,v in pairs(snarks[a]) do
			if attacker == k then
				snark.IsSnark = true
				snark.snark = k
			end
		end
	end
	if snark.IsSnark then
		snark.snark:EmitSound( "snarkgun/deploy.wav", 500, 100 )
	end
end
hook.Add("EntityTakeDamage", "Play Snark Attack Sounds", SnarkAttack)
hook.Add("PlayerShouldTakeDamage", "Play Snark Attack Sounds", SnarkAttack)

function SnarkBlast( ply, pos, snark )
	local blast = EffectData()
		blast:SetOrigin( pos )
		blast:SetScale(.1)
		util.Effect( "HelicopterMegaBomb", blast )
		util.BlastDamage(ply, ply, pos, BlastRadius, BlastDamage)
				
	local sounds
		if SERVER then
			sounds = ents.Create( "prop_physics" )
		end
		sounds:SetPos( pos )
		sounds:EmitSound( "snarkgun/die.wav", 500, 100 )
		sounds:EmitSound( "snarkgun/blast.wav", 500, 100 )
		sounds:Remove()
		
	snarks[ply][snark] = nil
end

function SWEP:Initialize()
	snarks[self.Owner] = {}
end

function SWEP:Deploy()
	if CLIENT then return end
	self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
	self.Weapon:EmitSound( "snarkgun/hunt" ..math.random(1, 3).. ".wav", 500, 100 )
	timer.Simple( 2, PlayIdle, self )
end

function ResetAttacking( self )
	self.attacking = false
end

function SWEP:PrimaryAttack()
	if self.Weapon:Clip1() <= 0 then return end
	self.Weapon:SetClip1( self.Weapon:Clip1() - 1 )
	
	self.Weapon:SetNextPrimaryFire(CurTime() + 1)
	timer.Simple( self.Primary.Delay - .2, ResetAttacking, self)
	timer.Simple( self.Primary.Delay - .1, ResetAnimations, self)
	self.attacking = true

	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
	
	self.Owner:EmitSound( "snarkgun/hunt" ..math.random(1, 3).. ".wav", 500, 100 )
	
	local trace = {}
		trace.start = self.Owner:GetShootPos()
		trace.endpos = self.Owner:GetShootPos() + (self.Owner:GetAimVector() * 50)
		trace.filter = self.Owner
	local tr = util.TraceLine( trace )
	
	local Angles = self.Owner:GetAngles()
		Angles.pitch = 0
		Angles.roll = 0
		
	timer.Simple( .2, SpawnSnark, self, tr, Angles )
end

function SpawnSnark( self, tr, Angles )

	local npc = ents.Create( "npc_headcrab" )
	
	local spawnflags = 0
		spawnflags = spawnflags + 256 // Long Visibility/Shoot 
		spawnflags = spawnflags + 512 // Fade Corpse
		spawnflags = spawnflags + 1024 // Think outside PVS
	npc:SetKeyValue("spawnflags", spawnflags)

	npc:SetAngles( Angles )
	npc:SetPos( tr.HitPos + tr.HitNormal * 2 )
	npc:SetMaterial( "models/v_squeak/snark" )
	npc:Spawn()
	npc:Activate()

	self.Owner:AddCleanup( "npcs", npc )
	snarks[self.Owner][npc] = {}
	snarks[self.Owner][npc].start = CurTime()
end

function SWEP:SecondaryAttack()
end


function SWEP:Initialize()
	if SERVER then
		self.Weapon:SetWeaponHoldType("melee")
	end
end 

Can someone give me a hint what is missing`?

Move
[lua]
SWEP.CanBuy = { ROLE_TRAITOR }
[/lua]

out of the if (CLIENT) then block

Oh shit youre so right. Now i can buy it. but i get some errors which i cannot translate well on the code:

[ERROR] lua/weapons/throwablesnark/shared.lua:241: bad argument #1 to ‘SetAngles’ (Angle expected, got nil)

  1. SetAngles - [C]:-1
  2. unknown - lua/weapons/throwablesnark/shared.lua:241

Timer Failed! [Simple][@lua/weapons/throwablesnark/shared.lua (line 228)]

[ERROR] lua/weapons/throwablesnark/shared.lua:233: attempt to call field ‘Create’ (a nil value)

  1. unknown - lua/weapons/throwablesnark/shared.lua:233

[ERROR] lua/weapons/throwablesnark/shared.lua:201: attempt to index local ‘self’ (a nil value)

  1. unknown - lua/weapons/throwablesnark/shared.lua:201

Timer Failed! [Simple][@lua/weapons/throwablesnark/shared.lua (line 209)]

Where is says npc:SetAngles( Angles ), nothing defines Angles. The only place where I see that defined is in the last function, but it is localised to that function only.

Allow me to translate the errors for you.

This means you’ve called ent:SetAngles( nil ) somewhere in your code.
A likely cause is you’re trying to using a variable that doesn’t have a value.
Double check your variables and make sure they have the correct values that you are expecting.

The “Timer Failed” line means the encasing function is being called by a timer.
Double check you’ve created the timer function correctly, and are passing the variables correctly.

I’m assuming this is an ents.Create(), and i’d bet you’re seeing this error on the client.
ents.Create doesn’t exist on client, and thus would throw this error.

“self” not being set usually means you’re calling the function as such: ent.MyFunction().
Make sure to use a : and not a .

The “Timer Failed” line here likely means you’re attempting to call the function directly, example: timer.Simple(0,self.MyFunction)
This example would throw the error you’re seeing here.

Make sure you’ve made the timer function so that it calls your function correctly.
The following are examples on how to pass the “self” variable to a function: ent.MyFunction(ent); ent:MyFunction(); MyFunction(ent);

Beyond that, perhaps you could tell us what you have already tried to fix this yourself?

Just a reminder, this forum is called Developer Discussion. Do not expect us to make this for you.
If you want to hire a coder, try visiting www.gmodstore.com