How to make my ragdoll smoother?

so ive made a ragdoll module that works just fine, but im having an issue with latency. i tried plenty of things, but the only thing ive come up with that at the least avoids flinging is using the humanoid state. i tried repositiong and orientation, but its always a bit into the ground before theyre fully standing up. i looked around the forums for a bit but so far nothing

function stunmod.ragdoll(char, attacker, timer)
	for index,joint in ipairs(char:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")
			a1.Parent = joint.Part0
			a2.Parent = joint.Part1
			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			
			char.Values.Ragdoll.Value = true
			joint.Enabled = false
			char.Humanoid.PlatformStand = true
			char.Humanoid.AutoRotate = false
			
			char.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
			
			for _, limb in ipairs(char:GetChildren()) do
				if limb.Name == "Right Arm" or limb.Name == "Left Arm" or limb.Name == "Right Leg" or limb.Name == "Left Leg" then
					local collision = game.ReplicatedStorage.RagdollCollisions:Clone()
					collision.Parent = char
					collision.CFrame = limb.CFrame
					collision.Transparency = 1
					
					local weld = Instance.new("WeldConstraint")
					weld.Parent = collision
					weld.Part0 = collision
					weld.Part1 = limb
					
					game.Debris:AddItem(collision, timer)
				end
			end
			
			local bv = Instance.new("BodyVelocity")
			bv.Parent = char.HumanoidRootPart
			bv.MaxForce = Vector3.new(1e5,1e5,1e5)
			bv.P = 1250
			bv.Velocity = attacker.HumanoidRootPart.CFrame.LookVector * 30
			
			game.Debris:AddItem(bv, 0.2)
			
			task.delay(timer, function()
				char.Humanoid.PlatformStand = false
				char.Humanoid.AutoRotate = true
				joint.Enabled = true
				char.Values.Ragdoll.Value = false
				
				char.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
				
				char.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position) * CFrame.Angles(0,0,0)
				
				socket:Destroy()
				a1:Destroy()
				a2:Destroy()
			end)
		end
	end
end

1 Like

What happens if you remove the char.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position) * CFrame.Angles(0,0,0) line.
It’s probably taking the current Position of the HRP on the ground and resetting the Humanoid there after being told to get up which seems redundant.

3 Likes

Don’t know if this will help but maybe set the player to the network owner of the model?

1 Like

Also did you see the most recent update about the beta ragdoll physics that are coming out? They look pretty nice.

2 Likes

its the same thing but theyre rotated a bit before fully standing

1 Like

i know thatd work, but the issue is that all the other clients would see it latent.

2 Likes