Ragdoll glitching and making player move strangely after combat combo

Hi DevForum,

I recently made a combat system with a ragdoll after the last combo attack, but the player who gets ragdolled, after getting back up, moves strangely.

Here is my script (It’s a function in a module script and called in a server script):

function RagdollModule.ragdollV2(Character, Value)
		Character.Humanoid.BreakJointsOnDeath = false
		Character.Humanoid.RequiresNeck = false
		local Motor6D_Table = {}
		local BallSocket_Table = {}

		local Weld = Instance.new("Weld")
		Weld.Part0 = Character.HumanoidRootPart
		Weld.Part1 = Character.Torso
		Weld.Enabled = false
		Weld.Parent = Character.HumanoidRootPart

		for index, Motor6D in pairs(Character:GetDescendants()) do
			if Motor6D:IsA("Motor6D") then
				table.insert(Motor6D_Table, Motor6D)
				local socket = Instance.new("BallSocketConstraint")
				table.insert(BallSocket_Table, socket)
				local a1 = Instance.new("Attachment")
				local a2 = Instance.new("Attachment")
				a1.Parent = Motor6D.Part0
				a2.Parent = Motor6D.Part1
				socket.Parent = Motor6D.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = Motor6D.C0
				a2.CFrame = Motor6D.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
			end
		end


	if Value >= 1 and Character:FindFirstChild("Humanoid") then
		Character.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
		
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("BasePart") then
				v.CanCollide = true
			end
		end
		
		Weld.Enabled = true
		Character.Humanoid.PlatformStand = true
		Character.Humanoid.AutoRotate = true
		for index, Motor6D in pairs(Motor6D_Table) do
			Motor6D.Enabled = false
		end

		for index, socket in pairs(BallSocket_Table) do
			socket.Enabled = true
		end

--				Character:SetAttribute("IFrames", Character:GetAttribute("IFrames")+1)

--				repeat wait() Character.Humanoid.WalkSpeed = 0 Character.Humanoid.JumpPower = 0 until Character:GetAttribute("Knocked") ~= Value
--				Character:SetAttribute("IFrames", Character:GetAttribute("IFrames")-1)
	end
	if Value <= 0 then
		Weld.Enabled = false
		Character.Humanoid.PlatformStand = false
		Character.Humanoid.AutoRotate = false
		for index, Motor6D in pairs(Motor6D_Table) do
			Motor6D.Enabled = true
		end

		for index, socket in pairs(BallSocket_Table) do
			socket.Enabled = false
		end
		
		Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
		
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("Part") then
				if v.Name == "Head" or v.Name == "HumanoidRootPart" then continue end
				
				v.CanCollide = false
			end
		end
		
	end
end

Here is the video:

1 Like

Hello there! Make sure to enabled back the AutoRotate of the Humanoid of the player when he gets unragdolled!

Character.Humanoid.AutoRotate = true
3 Likes

You can copy and paste the script below, it should work better :slight_smile:

function RagdollModule.ragdollV2(Character, Value)
		Character.Humanoid.BreakJointsOnDeath = false
		Character.Humanoid.RequiresNeck = false
		local Motor6D_Table = {}
		local BallSocket_Table = {}

		local Weld = Instance.new("Weld")
		Weld.Part0 = Character.HumanoidRootPart
		Weld.Part1 = Character.Torso
		Weld.Enabled = false
		Weld.Parent = Character.HumanoidRootPart

		for index, Motor6D in pairs(Character:GetDescendants()) do
			if Motor6D:IsA("Motor6D") then
				table.insert(Motor6D_Table, Motor6D)
				local socket = Instance.new("BallSocketConstraint")
				table.insert(BallSocket_Table, socket)
				local a1 = Instance.new("Attachment")
				local a2 = Instance.new("Attachment")
				a1.Parent = Motor6D.Part0
				a2.Parent = Motor6D.Part1
				socket.Parent = Motor6D.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = Motor6D.C0
				a2.CFrame = Motor6D.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
			end
		end


	if Value >= 1 and Character:FindFirstChild("Humanoid") then
		Character.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
		
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("BasePart") then
				v.CanCollide = true
			end
		end
		
		Weld.Enabled = true
		Character.Humanoid.PlatformStand = true
		Character.Humanoid.AutoRotate = false
		for index, Motor6D in pairs(Motor6D_Table) do
			Motor6D.Enabled = false
		end

		for index, socket in pairs(BallSocket_Table) do
			socket.Enabled = true
		end

--				Character:SetAttribute("IFrames", Character:GetAttribute("IFrames")+1)

--				repeat wait() Character.Humanoid.WalkSpeed = 0 Character.Humanoid.JumpPower = 0 until Character:GetAttribute("Knocked") ~= Value
--				Character:SetAttribute("IFrames", Character:GetAttribute("IFrames")-1)
	end
	if Value <= 0 then
		Weld.Enabled = false
		Character.Humanoid.PlatformStand = false
		Character.Humanoid.AutoRotate = true
		for index, Motor6D in pairs(Motor6D_Table) do
			Motor6D.Enabled = true
		end

		for index, socket in pairs(BallSocket_Table) do
			socket.Enabled = false
		end
		
		Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
		
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("Part") then
				if v.Name == "Head" or v.Name == "HumanoidRootPart" then continue end
				
				v.CanCollide = false
			end
		end
		
	end
end
2 Likes

Hi, thank you, this worked!

However, it started interfering with my animations like so below:

Is there anything I can do to fix this? Thanks!

Hey there! I remade the entire script for ya!

function RagdollModule.ragdollV2(Character, Value)

	if Value >= 1 and Character:FindFirstChild("Humanoid") then
		Character.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)

		Character.Humanoid.BreakJointsOnDeath = false
		Character.Humanoid.RequiresNeck = false
		local Motor6D_Table = {}
		local BallSocket_Table = {}

		local Weld = Instance.new("Weld")
		Weld.Name = "Ragdoll Weld"
		Weld.Part0 = Character.HumanoidRootPart
		Weld.Part1 = Character.Torso
		Weld.Enabled = false
		Weld.Parent = Character.HumanoidRootPart

		for index, Motor6D in pairs(Character:GetDescendants()) do
			if Motor6D:IsA("Motor6D") then
				table.insert(Motor6D_Table, Motor6D)
				local socket = Instance.new("BallSocketConstraint")
				socket.Name = "BallSocketRagdoll"
				table.insert(BallSocket_Table, socket)
				local a1 = Instance.new("Attachment")
				a1.Name = "attRagdoll"
				local a2 = Instance.new("Attachment")
				a2.Name = "attRagdoll"
				a1.Parent = Motor6D.Part0
				a2.Parent = Motor6D.Part1
				socket.Parent = Motor6D.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = Motor6D.C0
				a2.CFrame = Motor6D.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
			end
		end

		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("BasePart") then
				v.CanCollide = true
			end
		end

		Weld.Enabled = true
		Character.Humanoid.PlatformStand = true
		Character.Humanoid.AutoRotate = false
		for index, Motor6D in pairs(Motor6D_Table) do
			Motor6D.Enabled = false
		end

		for index, socket in pairs(BallSocket_Table) do
			socket.Enabled = true
		end

		--				Character:SetAttribute("IFrames", Character:GetAttribute("IFrames")+1)

		--				repeat wait() Character.Humanoid.WalkSpeed = 0 Character.Humanoid.JumpPower = 0 until Character:GetAttribute("Knocked") ~= Value
		--				Character:SetAttribute("IFrames", Character:GetAttribute("IFrames")-1)
	end
	if Value <= 0 then
		Character.Humanoid.AutoRotate = true
		Character.Humanoid.PlatformStand = false
		for index, Weld in pairs(Character.HumanoidRootPart:GetDescendants()) do
			if Weld:IsA("Weld") and Weld.Name == "Ragdoll Weld" then
				Weld:Destroy()
			end
		end

		for index, Motor6D in pairs(Character:GetDescendants()) do
			if Motor6D:IsA("Motor6D") then
				for index,socket in pairs(Motor6D.Parent:GetDescendants()) do
					if socket:IsA("BallSocketConstraint") and socket.Name == "BallSocketRagdoll" then
						socket:Destroy()
					end
				end
				for index, att in pairs(Motor6D.Part0:GetChildren()) do
					if att:IsA("Attachment") and att.Name == "attRagdoll" then
						att:Destroy()
					end
				end
				for index, att in pairs(Motor6D.Part1:GetChildren()) do
					if att:IsA("Attachment") and att.Name == "attRagdoll" then
						att:Destroy()
					end
				end
				Motor6D.Enabled = true
			end
		end
	end
end

I tested it and I think it should work fine now!
Have a nice day :slight_smile:

Ah thank you! You didn’t have to!

I was just curious as to what you fixed, if you would be able to give the details on what was the issue.

1 Like