Zombie flops around after being killed

I’ll try that, that might work

ok so unanchored after the animation and this what happens

you will need to get the CFrame of the torso before it pops back up, then move the humanoidRootPart to that CFrame.

1 Like

ok how do I get its current position every time, because if copy his position and then I kill him somewhere else the next time, his body moves to the last position I kill him?

function died()
	if myHuman.Health <= 0 then
		myHuman.Parent.HumanoidRootPart.Anchored = true
		dieAnim:Play()
		
		task.wait(1)
		--myHuman.Parent.HumanoidRootPart.Anchored = false
		myHuman.Parent.HumanoidRootPart.CFrame = CFrame.new() 
	end
end

myHuman.Died:Connect(died)
1 Like

I would achieve something like this:

function died()
    if myHuman.Health <= 0 then
		myHuman.Parent.HumanoidRootPart.Anchored = true
		dieAnim:Play()
		
		task.wait(0.5) --This is however long it is until the zombie falls to the floor
        local updateCF = myHuman.Parent.Torso.CFrame
        task.wait(0.5)
		myHuman.Parent.HumanoidRootPart.CFrame = updateCF
	end
1 Like

id of thought itd be an issue with humanoid states/the zombie not actually entering a dead state and/or being allowed to leave a dead state

.Died in humanoids is also incredibly weird, thank roblox for that one

1 Like

I’ve tried using myHuman:GetStateEnabled(Enum.HumanoidStateType.Dead, true) but he stands back up.

1 Like

He still stands back up after being killed smh this is so weird, not sure I’ve tried rag dolling him, anchoring him, changing his state to died, changing his Orientation, nothing seems to work and keep him on the ground.

1 Like

I have had this type of problem before, when I used pathfinding for an npc, I think it is due to the NetworkOwner, something that I solve for this type of problem is to use the function “:SetNetworkOwner()” what I would do is the following ,at the beginning of the main script put workspace.“ZombieName”.HumanoidRootPart:SetNetworkOwner(nil)

1 Like

Changing the NetworkOwner also helps to avoid bugs when changing the state of an npc with ChangeState(), sometimes the function did not change the state of my npc, but when using :SetNetworkOwner(nil) the error disappeared

1 Like

Something that I must clarify for you is that it is not necessary to apply this to the player characters, since their NetworkOwner is not the server but rather their Device itself, on the other hand, the npcs, since they are not players, their NetworkOwner is the server, and that is sometimes causes problems

1 Like

sill not changing him from standing back up after dying, I’m so confused

1 Like

Send me the model of your zombie so I can do some tests and find the error

2 Likes

Test Zombie.rbxm (41.4 KB)

1 Like

Looks like there’s a few issues going on.

Firstly, you are trying to set the humanoid state to dead by using “GetStateEnabled()” You need to use “SetStateEnabled()”

myHuman:SetStateEnabled(Enum.HumanoidStateType.Dead,true)

When you anchor a part, the NetworkOwnership is automatically set to the server. So no need to anchor the HumanoidRootPart then set the NetworkOwnership to nil after the zombie dies

Another thing is when a humanoid is fallen over, it will get up, which looks like what your zombie is doing, so you should disable the GettingUp state on the humanoid when they die.

function died()
	if myHuman.Health <= 0 then
		myHuman:SetStateEnabled(Enum.HumanoidStateType.Getting, false)
		myHuman:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
		myHuman.Parent.HumanoidRootPart.Anchored = true
		dieAnim:Play()
		
		task.wait(0.5) --This is however long it is until the zombie falls to the floor
		local updateCF = myHuman.Parent.Torso.CFrame
		task.wait(0.5)
		myHuman.Parent.HumanoidRootPart.CFrame = updateCF
	end
end

Also with animating, the animated limbs will go back to their original cframe after the animation is done playing. So you could anchor all the limbs once they are in the lying down position. But you’ll run into an issue where the limbs could hang over an edge without falling over since they are anchored.

So a hacky solution off the top of my head (Untested) would be to anchor all the limbs once they are in the lying down/dead position and set them to CanCollide true. Then destroy any welds connected to the HumanoidRootPart. Then you could replace the limb welds with Ball Constraints or something that would make them dangle around. Then unanchor all the limbs.

1 Like

nope still gets up, it’s unreal how hard it is to just make a dead NPC stay down smh

1 Like

Hey, I tried your zombie and the truth is that the problems you are having have not happened to me, when it died it did not move as if it received an impulse

1 Like

then the problem could be some other script that your game has, which interferes with the zombie’s

1 Like

By the way, to deal with the problem I am killing the zombie with the classic Roblox sword found in the toolbox, perhaps the problem is caused by the weapon in your game

2 Likes

Oh ok I’ll try not using the gun and see how he responds thank you for that, that could well be the problem

1 Like