Ragdoll System Problem

  1. What do I want to achieve?
    I want to make a simple R6 ragdoll system.

  2. What is the issue? (Video included)
    When a ragdolled character gets up after a ragdoll, he is thrown into the air and when landing he lies on the floor for a while.

  3. What solutions have I tried so far?
    Try №1: I tried using HumanoidStateType from the server and from the client, but it didn’t help.
    Try №2: I tried using BodyGyro on character’s torso and humanoidRootPart. (didn’t help either)
    Try №3: I tried editting character’s humanoidRootPart orientation when character gets up however it’s working but it’s looks really weird and doesn’t help always.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

My ModuleScript code:

local module = {}

function module.ragdoll(char)
	if char:FindFirstChild("Humanoid") and char.Humanoid.Health > 0 then
		if char:FindFirstChild("HumanoidRootPart") ~= nil and not char.HumanoidRootPart:FindFirstChild("ragdollsocket") then
			for index, joint in pairs(char:GetDescendants()) do
				if joint:IsA("Motor6D") then
					local a1 = Instance.new("Attachment",joint.Part0)
					a1.Name = "ragdoll_a1"
					a1.CFrame = joint.C0
					local a2 = Instance.new("Attachment",joint.Part1)
					a2.Name = "ragdoll_a2"
					a2.CFrame = joint.C1
					local socket = Instance.new("BallSocketConstraint",joint.Parent)
					socket.Name = "ragdollsocket"
					socket.LimitsEnabled = true
					socket.TwistLimitsEnabled = true
					socket.Attachment0 = a1
					socket.Attachment1 = a2
					joint.Enabled = false
				end
			end
			module.makefakelimb("Right Arm",char)
			module.makefakelimb("Left Arm",char)
			module.makefakelimb("Right Leg",char)
			module.makefakelimb("Left Leg",char)
			char:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.FallingDown) -- doesnt prevent character flinging x1
			char:WaitForChild("ragdolled").Value = true --- Humanoid.PlatformStand = ragdolled.Value
			print("ragdoll")
		end
	end
end
function module.unragdoll(char)
	if char:FindFirstChild("Humanoid") ~= nil and char.Humanoid.Health > 0 then
		if char:FindFirstChild("HumanoidRootPart") ~= nil and char.HumanoidRootPart:FindFirstChild("ragdollsocket") ~= nil then
			char:FindFirstChildOfClass("Humanoid"):ChangeState(Enum.HumanoidStateType.GettingUp) -- doesnt prevent character flinging x1
			char:WaitForChild("ragdolled").Value = false --- Humanoid.PlatformStand = ragdolled.Value
			for i2, v2 in pairs(char:GetChildren()) do
				if v2.Name:find("Fake") then
					v2:Destroy()
				end
			end
			for index,joint in pairs(char:GetDescendants()) do 
				if joint:IsA("Motor6D") then
					joint.Enabled = true
				end
			end
			for i, v in pairs(char:GetDescendants()) do
				if v.Name == "ragdollsocket" or v.Name == "ragdoll_a1" or v.Name == "ragdoll_a2" then
					v:Destroy()
				end
			end
			print("unragdoll")
			--[[local BodyGyro= Instance.new("BodyGyro", char:FindFirstChild("Torso")) -- didn't help
			BodyGyro.CFrame = CFrame.new(char:FindFirstChild("Torso").Position,Vector3.new(0,char:FindFirstChild("Torso").Orientation.Y,char:FindFirstChild("Torso").Orientation.Z))
			game.Debris:AddItem(BodyGyro, 0.25)]]
			--[[wait(0.1)
			char:FindFirstChild("Torso").Orientation = Vector3.new(char:FindFirstChild("Torso").Orientation.X-(char:FindFirstChild("Torso").Orientation.X*0.5),char:FindFirstChild("Torso").Orientation.Y,char:FindFirstChild("Torso").Orientation.Z)]] -- prevents character fling but looks really weird and sometimes doesnt help
		end
	end
end
function module.makefakelimb(name,parent)
	if parent:FindFirstChild(name) ~= nil then
		local FakeLimb = Instance.new("Part", parent)
		FakeLimb.Transparency = 1
		FakeLimb.Massless = true
		FakeLimb.Size = Vector3.new(0.8, 1.6, 0.8)
		FakeLimb.Position = parent:FindFirstChild(name).Position
		FakeLimb.Orientation = parent:FindFirstChild(name).Orientation
		FakeLimb.Name = "Fake "..name
		FakeLimb.Parent = parent
		FakeLimb.CanCollide = true
		FakeLimb.CanTouch = false
		local weld = Instance.new("WeldConstraint", FakeLimb)
		weld.Part0 = FakeLimb
		weld.Part1 = parent:FindFirstChild(name)
	end
end

return module

I’ve been trying to find a solution for a month now, but nothing helps. I hope by creating this topic, I will finish my ragdoll system

I had the same issue. To fix this, just set the CFrame of the humanoid root part to CFrame.new(humanoidRootPart.Position)

4 Likes

I tested it out. And it solved my issue! Thanks you, SubtotalAnt8185!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.