[LUA Scripting Question] Spawning a ragdoll with a pose?

Hello, I’ve been trying to make a ragdoll when you kill somebody like in TTT, but the ragdoll appears in T-Pose, I can actually put a pose or “animation” to it? And how?
Thanks for awnsering.

You need to loop through each bone of the ragdoll/player and align them.

EDIT: Like this (code taken from a gmod12 addon and tweaked, so it may not work, but should give you the idea)

[lua]

victim = thePlayerWhoDied
ragObj = yourNewRagdoll


--Loop through each bone
local numberOfBones = ragObj:GetPhysicsObjectCount()
for i = 1, numberOfBones - 1 do
	
	local ragBone = ragObj:GetPhysicsObjectNum( i )	--Get the current bone
	
	if IsValid( ragBone ) then	
		
		local vicBonePos, vicBoneAng = victim:GetBonePosition( ragObj:TranslatePhysBoneToBone( i ) )  --get the position of the bone on the player
			
		ragBone:SetPos( vicBonePos) --set the ragdoll bone position to the player bone position
		ragBone:SetAngle( vicBoneAng )
		
		ragBone:SetVelocity( ragObj:GetVelocity() )
		
	end
	
end

[/lua]