Hello all, my game has a ragdoll feature for when the player dies, and if the player is, for lack of a better term, stunned. Since the character’s body parts never collide while they’re alive, I’ve had to make invisible parts that serve as the collision for them.
While it works fine with the legs, the arms won’t budge.
The posts I found either had solutions that no longer work, or didn’t help me.
--This is a StarterCharacterScripts script
local char = script.Parent;
char:WaitForChild("Humanoid").BreakJointsOnDeath = false
function checkRagoll()
for i, v in pairs(char:GetChildren()) do
if v.Name == "Ragdolled" then
return true
end
end
return false
end
local non_ragdoll = {"Head", "Left Arm", "Torso", "Right Arm", "Left Leg", "Right Leg", "HumanoidRootPart"}
--These are the parts not to be destroyed during the recovery
function recover()
if checkRagoll() and char.Humanoid.Health > 0 then
char.Ragdolled:Destroy()
for i, v in next, char:GetDescendants() do
if v:IsA("BallSocketConstraint") then
v:Destroy()
elseif v:IsA("Motor6D") then
v.Enabled = true
elseif v:IsA("Part") and not table.find(non_ragdoll, v.Name) and not v.Parent:IsA("Accessory") or v:IsA("Hat") and not v:FindFirstAncestorOfClass("Tool") then
v:Destroy()
end
end
end
end
function ragdoll()
if checkRagoll() then return end
local ragdolled = Instance.new("BoolValue") do
ragdolled.Name = "Ragdolled"
ragdolled.Parent = char
end
for i, m6d in next, char:GetDescendants() do
if m6d:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = m6d.C0
a1.CFrame = m6d.C1
a0.Parent = m6d.Part0
a1.Parent = m6d.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = m6d.Parent
m6d.Enabled = false
if not a1.Parent then return end
local fake_part = a1.Parent:Clone() do
fake_part.Parent = char
fake_part.Name = m6d.Name
fake_part.CanCollide = true
fake_part.Transparency = 1
fake_part.CollisionGroupId = 0
for i, v in next, fake_part:GetChildren() do
if v:IsA("Decal") or v:IsA("BodyMover") then
v:Destroy()
end
end
local weld = Instance.new("WeldConstraint") do
weld.Parent = fake_part
weld.Part0 = fake_part
weld.Part1 = m6d.Part1
end
end
end
end
end
char.Humanoid.Died:Connect(function()
ragdoll()
local newFace = char.Head.face:Clone()
newFace.Parent = char.Head
char.Head.face:Destroy()
newFace.Texture = 'rbxassetid://25891571'
end)
char.Humanoid.GettingUp:Connect(recover)
char.Humanoid.Ragdoll:Connect(ragdoll)
char.Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.PlatformStanding then
ragdoll()
wait(3)
char.Humanoid.PlatformStand = false
recover()
end
end)
If I need to explain some more, let me know! Any and all help is greatly appreciated ![]()