Weapon
A weapon inside the game. Giving, removing and reading the weapons of players is done on the player objects instead (see Player), with weapon names from the weapons list.
Available on: Client
A weapon inside the game, returned by player:GetWeapon() (the weapon the player currently holds). It is a game object: local to this client, owned by the game, and only valid while that weapon exists. Fetch it again when you need it instead of storing it; after the player switches or drops the weapon, an old Weapon value must not be used.
It has the methods every game object type has: GetPosition, GetRotation and GetEulerRotation give the weapon's real transform, and GO returns its GameObject part. Destroy does nothing on a weapon, since scripts never spawn weapons.
Example
-- mark where the local player's current weapon is
Event.Add("OnRender", function()
local weapon = World.LocalPlayer():AsPlayer():GetWeapon()
if weapon then
Render.DrawSphere(weapon:GetPosition(), 0.05, vec4(1, 0, 0, 1), false)
end
end)