Im making a game with ragdoll and I want to attempt something like what Ragdoll Universe has here. I know it has to do with something with constraints but what I have is not cutting it.
Code Im Using That Doesn’t Work Good:
for index, joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a0 = Instance.new("Attachment")
local a1 = Instance.new("Attachment")
a0.Parent = joint.Part0
a1.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.CFrame = joint.C0
a1.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
If you only want your arms to move just like in RAGDOLL UNIVERSE I recommend you to use this script:
for index, joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") and (joint.Name == "Left Shoulder" or joint.Name == "Right Shoulder") then
print(joint.Name)
local socket = Instance.new("BallSocketConstraint")
local a0 = Instance.new("Attachment")
local a1 = Instance.new("Attachment")
a0.Parent = joint.Part0
a1.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.CFrame = joint.C0
a1.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
for i, v in pairs(script.Parent:GetChildren()) do
-- Ensure that parts do not collide
if v:IsA("Part") then
v.CanCollide = false
end
end