The ragdoll created by the function CreateRagdoll() seems to be not an Entity


I’m using the function “Player:CreateRagdoll()” to spawn a player ragdoll.
I would like to damage the player if I shoot the ragdoll, the problem is that the hook “EntityTakeDamage” seems to be not called when a ragdoll get shooted.

Any help?

The ragdoll created by CreateRagdoll() is a clientside entity. EntityTakeDamage is serverside. I think it’d work if you can find a hook for clientside damage.

Do you know if there is another way to spawn a player ragdoll?

This might work, but I’m not sure


I tried it, but nothing is changed!

[editline]27th June 2017[/editline]

If I kill a player and I shoot his body, the hook “EntityTakeDamage” get called!
But I don’t know why now, when I kill somebody, it creates 2 different ragdolls ( I think 1 is client and 1 server)

Remove the clientside ragdoll in


Ok, but my problem is that only when the player dies it spawns a server ragdoll. Why?

Because SetShouldServerRagdoll is true.

Sorry my bad.
My question was:
When I spawn a player ragdoll using the function “Player:CreateRagdoll()”, this ragdoll is client side.
I would like to use the hook “EntityTakeDamage” to handle the ragdoll damage but I can’t because the ragdoll is client side.

I used the function SetShouldServerRagdoll(true) to make the ragdoll that I spawn server side.
The problem is that when I spawn the ragdoll using the function “Player:CreateRagdoll()” it continue to be a client side ragdoll, but when a player dies, spawns a server side ragdoll.

I have understood this, but my problem isn’t this!

You want to remove the ragdoll, use that hook to remove the ragdoll…Simple like that

I think he just wants to know when the regular clientside ragdoll takes damage, not actually use a server side ragdoll at all.

Nono, guys, excuse me but I’m not English so I check to explain it as good as I can.

I post some code to explain it!

hook.Add("PlayerSpawn", "playerSpawned", function(ply)
       timer.Simple(100, function()
            ply:SetShouldServerRagdoll( true )

Now the player’s ragdoll is spawned, I want that if somebody shoots this ragdoll, the Owner of this ragdoll will be damaged, so:

hook.Add("EntityTakeDamage", "entityDamaged", function(target, dmg)
	if target:IsRagdoll() and IsValid(target:GetRagdollOwner()) and target:GetRagdollOwner():Alive() then
		local ply = target:GetRagdollOwner()
		ply:TakeDamage( dmg:GetDamage(), dmg:GetAttacker(), dmg:GetInflictor() )

The problem is that the ragdoll that I spawned IS CLIENTSIDE, then, I can’t handle it using the “EntityTakeDamage” hook.
I know that the ragdoll should be server side, because I called this function “ply:SetShouldServerRagdoll( true )”, but it doesn’t happen.

Only when the player dies he spawns 2 different ragdolls, 1 client side and 1 server side. ( I know that I can remove the client side ragdoll, but isn’t this my problem, my problem is that the server side ragdoll spawns only when the player dies and not when I call the function “Player:CreateRagdoll() )”