Head remove problem.

Sorry for creating another thread for this.

	local trace = {}
		trace.start = self.Owner:GetShootPos()
		trace.endpos = trace.start + (self.Owner:GetAimVector() * 1000)
		trace.filter = { self.Owner, self.Weapon }
		local tr = util.TraceLine( trace )
						if ( tr.HitGroup == HITGROUP_HEAD ) then
			if string.find(tr.Entity:GetClass(), "prop_ragdoll") then
				local Bone = tr.Entity:LookupBone("ValveBiped.Bip01_Head1")
				tr.Entity:ManipulateBoneScale( Bone, Vector(0,0,0)) 

Even if I hit the leg and kill NPC, his or her head will dissapear if I look at the dead body, if I replace “prop_ragdoll” with “npc_*”, then the head removes when I look at it.
I’ve also tried adding

						if tr.Entity:Health() < 0 then
			if string.find(tr.Entity:GetClass(), "npc_*") then

But that does nothing.
I have no idea how to fix this, help please.

Is the issue that the head disappears just by looking at it?


Is the issue that the head disappears when you look at any part of them, not just the head?

Case 1: You’re probably not calling the trace when they attack. I’m guessing you’re calling it every frame. Where is this code located? (give us some surrounding code.)
[editline]just saw your other thread[/editline]
Saw your other thread. You’ve got it in SWEP:Think(). Put it in SWEP:PrimaryAttack().

Case 2: You could try to instead find the tr.HitPos’s Distance to the head bone. For example:
local bone = tr.Entity:LookupBone(“ValveBiped.Bip01_Head1”)
if tr.Entity:GetBonePosition(bone):Distance(tr.HitPos) < 10 then --might be more or less than 10.
tr.Entity:ManipulateBoneScale( bone, Vector(0,0,0))
You might also look up how TTT handles headshots.

It dissapears when I look at the dead body’s head with this weapon. Also I couldn’t fix it with the code you gave.

The solution, if that is the problem, is to move your head-popping code to the SWEP:PrimaryAttack part of your weapon.