Weapon ViewModel Material Won't Reset

Hello all,

Currently for a SWEP, I’m doing:


function SWEP:PreDrawViewModel(vm, wep, ply)
	vm:SetMaterial( "engine/occlusionproxy" )
end

I’m trying to revert that when the player re-spawns (because the player has been spectated, it won’t work during :Holster()) but with no luck. I have right now:

lua/autorun/server.lua



function ResetViewModelMat(ply)
	timer.Simple(2, function()
		if ( IsValid( ply ) ) then
       		local vm = ply:GetViewModel()
       		print("Material:", vm:GetMaterial())
	        if ( IsValid( vm ) ) then 
	        	vm:SetMaterial( "" ) 
	        	print("Reset!", vm)
	        end
	        print("Resetting view model mat..", IsValid(vm))
   		end
	end)
end

hook.Add("PlayerSpawn", "ResetVMMat", ResetViewModelMat)

Any ideas how to fix it? The material won’t revert for some reason. Prints are in order: “Material:”, " ", “Reset!”, “Entity[number][PredictedViewModel]”, “Resetting view model mat…”, “true”