Garry's Mod Wiki

Player:GetActiveWeapon

  Weapon Player:GetActiveWeapon()

Description

Returns the player's active weapon.

If used on a LocalPlayer() and the player is spectating another player with OBS_MODE_IN_EYE, the weapon returned will be of the spectated player.

Returns

1 Weapon
The weapon the player currently has equipped or NULL if the player doesn't have an active weapon eg. when they're dead.

Example

Prints the player's active weapon's class name.

Output: The active weapon's class. For example, if you are holding the tool gun then this will be "gmod_tool".