I was making myself a ragdoll system I could use, and I made a little button to test out the system. It worked… with a weird effect.
Players kinda slump over and are able to “walk”. Now, I’m not complaining, it’s kinda funny, but it’s not ideal. How do I prevent this particular issue?
Module script:
local module = {}
function module.RagdollAdd(character)
for i,joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
print("Ragdolled!")
end
end
end
function module.RagdollRemove(character)
for i,socket in pairs(character:GetDescendants()) do
if socket:IsA("BallSocketConstraint") or "Attachment" then
socket:Destroy()
for i,joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
print("Unragdolled!")
end
end
end
return module
Button script:
local RagdollSystem = require(game.ReplicatedStorage.RagdollSystem)
local cd = script.Parent
cd.MouseClick:Connect(function(plr)
local character = plr.Character
RagdollSystem.RagdollAdd(character)
end)