Hi. I'm currently trying to script persistent ragdolls, and I'm having problems with collisions. What I mean is I create parts identical to the ragdoll's body parts and weld them together to create collisions. If I do this, the ragdoll has severe seizures. Currently I'm using collision groups to prevent the collision parts from colliding with each other, but that comes out with minor spasms and unrealistic ragdolls (limbs going through each other). Any idea how I can fix this?

local hum = script.Parent:FindFirstChildOfClass("Humanoid")
local aliveChar = script.Parent
local player = game.Players:GetPlayerFromCharacter(aliveChar)
local storage = game.ServerStorage
local ran = false
local physics = game:GetService("PhysicsService")
local ragdollParts = "RagdollParts"

aliveChar.Humanoid.BreakJointsOnDeath = false

hum.HealthChanged:Connect(function(health)
	if health <= 0 and not ran then
		ran = true
		aliveChar.Archivable = true
		local char = aliveChar:Clone()
		char.Parent = workspace
		char:SetPrimaryPartCFrame(aliveChar.PrimaryPart.CFrame)
		aliveChar:Destroy()
		char.Name = "Ragdoll"
		char.Humanoid.PlatformStand = true
		char.Head.face.Texture = "http://www.roblox.com/asset/?id="..15637705
		for i,v in pairs(char:GetChildren()) do
			if v:IsA("MeshPart") or v:IsA("UnionOperation") then
				print(v.Name)
				v:SetNetworkOwner(nil)
				if v.Name ~= "HumanoidRootPart" then
					local part = Instance.new("Part")
					part.Size = v.Size
					part.Transparency = 1
					part.Name = "RagdollPart"
					part.Parent = char
					physics:SetPartCollisionGroup(part, ragdollParts)
					part.Massless = true
					for i,child in pairs(part:GetChildren()) do
						child:Destroy()
					end
					local weld = Instance.new("Weld")
					weld.Parent = v
					weld.Part0 = v
					weld.Part1 = part
				end
			end
		end
		for i,v in pairs(char:GetDescendants()) do
			if v:IsA("Motor6D") then
				if v.Parent.Name ~= "BodyAttach" and v.Name ~= "WeaponAttach" then
					local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
					a0.CFrame = v.C0
					a1.CFrame = v.C1
					a0.Parent = v.Part0
					a1.Parent = v.Part1

					local b = Instance.new("BallSocketConstraint")
					b.Attachment0 = a0
					b.Attachment1 = a1
					b.TwistLimitsEnabled = true
					if string.find(v.Name, "Ankle") then
						b.TwistLowerAngle = -20
						b.TwistUpperAngle = 40
					elseif string.find(v.Name, "Knee") then
						b.TwistLowerAngle = 0
						b.TwistUpperAngle = 40
					elseif string.find(v.Name, "Elbow") then
						b.TwistLowerAngle = 40
						b.TwistUpperAngle = 0
					elseif string.find(v.Name, "Shoulder") then
						b.TwistLowerAngle = 0
						b.TwistUpperAngle = 40
					elseif string.find(v.Name, "Hip") then
						b.TwistLowerAngle = 0
						b.TwistUpperAngle = 0
					elseif string.find(v.Name, "Wrist") then
						b.TwistLowerAngle = -1.5
						b.TwistUpperAngle = 1.5
					elseif string.find(v.Name, "Neck") then
						b.TwistLowerAngle = -1.5
						b.TwistUpperAngle = 1.5
					else
						b.TwistLowerAngle = -10
						b.TwistUpperAngle = 10
					end
					b.Parent = v.Part0

					v:Destroy()
				end
			end
		end
		char.Humanoid.HealthDisplayDistance = 0
		char.Humanoid.Health = 0
		char.Health:Destroy()
		char.HumanoidRootPart:Destroy()
		game.Debris:AddItem(char, 12)
		wait(5)
		player:LoadCharacter()
	end
end)

2 comments

0

Im not sure about this but theres something called inner box and outer box collisions on game avatar settings. I havent worked with ragdolls, though, so im not sure if that would prevent body parts from clipping,

0

Oh, I believe that is something to do with R15's many animation packs and whatnot.. Correct me if I'm wrong.