• GetActiveWeapon Is nil value
    5 replies, posted
I'm fairly new to glua and I'm trying to make it so that when an entity identifies when it is hit by the SWEP I made (a wrench) in order to simulate repairing the entity on a basic level, however i get a lua error saying that GetActiveWeapon is a nil value. function ENT:OnTakeDamage(info)     local attacker = info:GetAttacker()     if attacker:GetActiveWeapon():GetClass() == "weapon_wrench" then         PrintMessage(HUD_PRINTTALK, "works")     end end Thanks in advance.
That cleared it all up, thanks a bunch.
when i created my hud "GetActiveWeapon" didnt worked when youre dead, which i fixed with if IsValid, but it seems you got it fixed now. so....what am i even doing here
That's because GetActiveWeapon returns NULL when the player is dead, just as it would if they were holding no weapon.
yea..that answer comes a little late. i know that for ages XD
Sorry, you need to Log In to post a reply to this thread.