Exchanging Weapons

So I have been using LUA for about a month now and I am still slightly new, but there is one thing I have not been able to figure out at all.

I coded an object that allows you to press USE and it will exchange whatever weapon you are currently holding with an upgraded one. I can’t figure out how to identify the held object.

if activator:GetActiveWeapon():Type("weapon_te3_glock17") then

I know that isn’t the code but I have tried multiple others such as

if activator:GetActiveWeapon() == "weapon_te3_glock17" then
					activator:Give("weapon_te3_upgraded_glock17") end

Any help would be awesome! :slight_smile:

To get the weapon’s class, use

I also advise you check if the active weapon is valid, then do the class check, for example:

local Weapon = Activator:GetActiveWeapon()

if ( IsValid( Weapon ) and Weapon:GetClass() == "weapon_te3_glock17" ) then

Omg it worked you just saved me hours of random codes XD that was a lot simpler than I thought. Thanks so much!