I am working on a game and players who die are supposed to ragdoll but the ragdolls are statue like
they just stand still and I can push them over, sometimes the head gets ragdolled but the rest of the body is still, any help?
Here is my ragdoll script:
local RootLimbData = {
{
[“WeldTo”] = “LowerTorso”,
[“WeldRoot”] = “HumanoidRootPart”,
[“AttachmentName”] = “Root”,
[“NeedsCollider”] = false,
[“UpperAngle”] = 10
},
{
[“WeldTo”] = “UpperTorso”,
[“WeldRoot”] = “LowerTorso”,
[“AttachmentName”] = “Waist”,
[“ColliderOffset”] = CFrame.new(0, 0.001, 0),
[“UpperAngle”] = 0
},
{
[“WeldTo”] = “Head”,
[“WeldRoot”] = “UpperTorso”,
[“AttachmentName”] = “Neck”,
[“ColliderOffset”] = CFrame.new(),
[“UpperAngle”] = 20
},
{
[“WeldTo”] = “LeftUpperLeg”,
[“WeldRoot”] = “LowerTorso”,
[“AttachmentName”] = “LeftHip”,
[“ColliderOffset”] = CFrame.new(0.005, -0.210, -0.3)
},
{
[“WeldTo”] = “RightUpperLeg”,
[“WeldRoot”] = “LowerTorso”,
[“AttachmentName”] = “RightHip”,
[“ColliderOffset”] = CFrame.new(0.005, -0.210, -0.3)
},
{
[“WeldTo”] = “RightLowerLeg”,
[“WeldRoot”] = “RightUpperLeg”,
[“AttachmentName”] = “RightKnee”,
[“ColliderOffset”] = CFrame.new(0.005, -0.210, -0.3)
},
{
[“WeldTo”] = “LeftLowerLeg”,
[“WeldRoot”] = “LeftUpperLeg”,
[“AttachmentName”] = “LeftKnee”,
[“ColliderOffset”] = CFrame.new(0.005, -0.210, -0.3)
},
{
[“WeldTo”] = “RightUpperArm”,
[“WeldRoot”] = “UpperTorso”,
[“AttachmentName”] = “RightShoulder”,
[“ColliderOffset”] = CFrame.new(0, 0.4, 0.1),
},
{
[“WeldTo”] = “LeftUpperArm”,
[“WeldRoot”] = “UpperTorso”,
[“AttachmentName”] = “LeftShoulder”,
[“ColliderOffset”] = CFrame.new(0, 0.4, 0.1),
},
{
[“WeldTo”] = “LeftLowerArm”,
[“WeldRoot”] = “LeftUpperArm”,
[“AttachmentName”] = “LeftElbow”,
[“ColliderOffset”] = CFrame.new(0, 0.350, 0.3),
[“UpperAngle”] = 10
},
{
[“WeldTo”] = “RightLowerArm”,
[“WeldRoot”] = “RightUpperArm”,
[“AttachmentName”] = “RightElbow”,
[“ColliderOffset”] = CFrame.new(0, 0.350, 0.3),
[“UpperAngle”] = 10
},
{
[“WeldTo”] = “RightHand”,
[“WeldRoot”] = “RightLowerArm”,
[“AttachmentName”] = “RightWrist”,
[“ColliderOffset”] = CFrame.new(0, 0.125, 0),
[“UpperAngle”] = 0
},
{
[“WeldTo”] = “LeftHand”,
[“WeldRoot”] = “LeftLowerArm”,
[“AttachmentName”] = “LeftWrist”,
[“ColliderOffset”] = CFrame.new(0, 0.125, 0),
[“UpperAngle”] = 0
},
{
[“WeldTo”] = “LeftFoot”,
[“WeldRoot”] = “LeftLowerLeg”,
[“AttachmentName”] = “LeftAnkle”,
[“NeedsCollider”] = false,
[“UpperAngle”] = 0
},
{
[“WeldTo”] = “RightFoot”,
[“WeldRoot”] = “RightLowerLeg”,
[“AttachmentName”] = “RightAnkle”,
[“NeedsCollider”] = false,
[“UpperAngle”] = 0
},
}
function RagdollV2(char, hide_name)
local hdv = char:FindFirstChild("Head")
--set up the ragdoll
local function scan(ch)
for i = 1, #ch do
scan(ch[i]:GetChildren())
if ch[i]:IsA("ForceField") or ch[i]:IsA("Motor6D") or (ch[i].Name == "HumanoidRootPart") or (ch[i]:IsA("Weld") and ch[i].Name ~= "HeadWeld" and ch[i].Name ~= "RadioWeld" and ch[i].Name ~= "AccessoryWeld") then
ch[i]:destroy()
end
end
end
scan(char:GetChildren())
local fhum = Instance.new("Humanoid")
fhum.RigType = Enum.HumanoidRigType.R15
fhum.Parent = char
fhum.Sit = true
if hide_name then
fhum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end
local Torso = char:FindFirstChild("UpperTorso")
for i=1,#RootLimbData do
local limbData = RootLimbData[i];
local partName = limbData["WeldTo"];
local weldName = limbData["WeldRoot"];
local PartTo = char:FindFirstChild(partName);
local WeldTo =char:FindFirstChild(weldName);
if ( PartTo ~= nil and WeldTo ~= nil ) then
if ( char ~= nil ) then
local scale = 20;
local vecX = (math.random()-math.random())*scale;
local vecY = (math.random()-math.random())*scale;
local vecZ = (math.random()-math.random())*scale;
PartTo.Velocity = PartTo.Velocity + Vector3.new(vecX, vecY, vecZ);
end
-- Create New Constraint
local UpperAngle = limbData["UpperAngle"]
local Joint = Instance.new("BallSocketConstraint")
if ( (UpperAngle ~= nil and UpperAngle == 0) ) then
Joint = Instance.new("HingeConstraint")
Joint.UpperAngle = 0
Joint.LowerAngle = 0
end
Joint.Name = limbData["AttachmentName"]
Joint.LimitsEnabled = true
Joint.UpperAngle = 30
Joint.Attachment0 = PartTo:FindFirstChild(Joint.Name .. "RigAttachment")
Joint.Attachment1 = WeldTo:FindFirstChild(Joint.Name .. "RigAttachment")
Joint.Parent = PartTo
if ( UpperAngle ~= nil ) then
Joint.UpperAngle = UpperAngle
end
-- Destroy the motor attaching it
-- Create Collider
local needsCollider = limbData["NeedsCollider"]
if ( needsCollider == nil ) then
needsCollider = true
end
if ( needsCollider ) then
local B = Instance.new("Part")
B.CanCollide = true
B.TopSurface = 0
B.BottomSurface = 0
B.formFactor = "Symmetric"
B.Size = Vector3.new(0.7, 0.7, 0.7)
B.Transparency = 1
B.BrickColor = BrickColor.Red()
B.Parent = char
local W = Instance.new("Weld")
W.Part0 = PartTo
W.Part1 = B
W.C0 = limbData["ColliderOffset"]
W.Parent = PartTo
end
end
end
spawn(function()
while wait() do
for _,i in pairs(char:GetDescendants()) do
if i:IsA("Motor6D") then
i:Destroy()
end
end
end
end)