Function Continuing Right Past Checks That Should Stop It?

Maybe I’m just missing something really obvious here, but here is where I don’t under stand.

function WeaponHud()
local user = LocalPlayer()

if !user:GetActiveWeapon() or !user:Alive() then return end

    local wep = user:GetActiveWeapon():GetClass()


hook.Add(“HUDPaint”, “WeaponHud”, WeaponHud)

For some reason when I die I am getting a error because user:GetActiveWeapon():GetClass() is NULL, but it shouldn’t have even gotten to that part of the code if I’m dead right?

If you die, the function Player:GetActiveWeapon no longer exists so you must check if it exists or not. Either more :Alive to the left or add if !ply.GetActiveWeapon then return end.

Entities ( including NULL ) evaluate to true.

if not ( user:Alive( ) and user:GetActiveWeapon( ):IsValid( ) ) then

-snip- What Kogitsune said, that works fine for Weapons.

Thanks a lot! Also thanks for the reply Robot