Help with pointshop

So what I want to do is basically make something in point shop that when equipped will simply take a weapon from the player and give him another.


function ITEM:OnEquip(ply, modifications)
	for k, v in pairs (ents.GetAll()) do
		ply:HasWeapon("weapon_ttt_bomb2")
	
        if  ply:HasWeapon("weapon_ttt_bomb2") then
		ply:StripWeapon("weapon_ttt_bomb2")
		ply:Give("weapon_ttt_bomb1")
		end
	end
end

Basically, what I am trying to do is cycle through all entities, and then check if the player has a weapon (In this case “weapon_ttt_bomb2”) and then if the player does to strip that weapon and give him another (In this case “weapon_ttt_bomb1”)

I have tried everything I could think of, but I can’t seem to get it to work. Any suggestions?

First of all, your loop is completely useless. You’re running the same commands over and over again (Note that your loop is for k, v and you only use ply in your code).
If you just remove the loop part it should work, depends on what you want to do.

OnEquip is called whenever the player spawns, so if the player doesn’t automatically have weapon_ttt_bomb2 when he spawns - the if statement will always return false.
Is this item a SingleUse? When exactly do you want to change (strip & give) the weapon?


ITEM.Name = 'Deathstation'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.SingleUse = false

function ITEM:OnEquip(ply, modifications)
	for k, v in pairs (ents.GetAll()) do
		ply:HasWeapon("weapon_ttt_bomb2")
			if  ply:HasWeapon("weapon_ttt_bomb2") then
				ply:StripWeapon("weapon_ttt_bomb2")
				ply:Give("weapon_ttt_bomb1")
		end
	end
end
function ITEM:OnHolster(ply)
if  ply:HasWeapon("weapon_ttt_bomb1") then
ply:StripWeapon("weapon_ttt_bomb1")
ply:Give("weapon_ttt_bomb2")
end
end

Sorry, this is the full code for the point shop item. Basically, what I want to happen is for when this item is equipped that it will constantly check to see if a player has a weapon, then if it returns that to be true, I want that weapon to be taken from the player and then for it to give him another weapon.

So in other words like an upgraded weapon. The player starts with the default weapon, but once he buys this pointshop item it will make it so every time he tries to equip the default weapon he is given an upgraded weapon. I am on TTT btw, don’t know if it helps.

Define ply for starters :slight_smile:

Pointshop already defines it as “LocalPlayer”