Basically, whenever this runs… instead of a ragdoll happening, the player just stays stiff but like stunned… any help?
local Ragdoll = {}
local rs = game:GetService("ReplicatedStorage")
local sss = game:GetService("ServerScriptService")
local plrs = game:GetService("Players")
local enableRagdoll = game.ReplicatedStorage.Events.enableRagdoll
function Ragdoll:Enable(character, duration)
print(character)
print(duration)
if character then
local humanoid = character:FindFirstChild("Humanoid")
local root = character:FindFirstChild("HumanoidRootPart")
local torso = character:FindFirstChild("Torso")
if humanoid and root and torso then
if duration then
task.delay(duration, function()
self:Disable(character)
end)
end
humanoid.AutoRotate = false
humanoid.PlatformStand = true
if plrs:FindFirstChild(character.Name) then
enableRagdoll:FireClient(plrs[character.Name], true)
end
local rootWeld = Instance.new("Weld")
rootWeld.Part0 = root
rootWeld.Part1 = torso
rootWeld.Name = "RootWeld"
rootWeld.Parent = character
for _, object in ipairs(character:GetDescendants()) do
if object:IsA("BasePart") then
local joint = object:Clone()
joint:ClearAllChildren()
joint.Size = Vector3.new(1,1,.5)
joint.Transparency = 1
joint.CanCollide = true
joint.Name = "Joint"
joint.Massless = true
joint.Parent = object
local weld = Instance.new("Weld")
weld.Part0 = joint
weld.Part1 = object
weld.Parent = joint
end
end
local motors = {torso:FindFirstChild("Left Hip"), torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Hip"), torso:FindFirstChild("Right Shoulder")}
for i = 1, #motors do
if motors[i].ClassName == "Motor6D" then
motors[i].Enabled = false
end
end
end
end
end
function Ragdoll:Disable(character)
if character then
local humanoid = character:FindFirstChild("Humanoid")
local root = character:FindFirstChild("HumanoidRootPart")
local torso = character:FindFirstChild("Torso")
if humanoid and root and torso then
humanoid.AutoRotate = true
if character:FindFirstChild("RootWeld") then
character["RootWeld"]:Destroy()
end
root.Velocity = Vector3.new(0,0,0)
for _, object in ipairs(character:GetDescendants()) do
if object:IsA("BasePart") then
if object.Name == "Joint" then
object:Destroy()
end
end
end
humanoid.PlatformStand = false
if plrs:FindFirstChild(character.Name) then
enableRagdoll:FireClient(plrs[character.Name], false)
end
local motors = {torso:FindFirstChild("Left Hip"), torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Hip"), torso:FindFirstChild("Right Shoulder")}
for i = 1, #motors do
if motors[i].ClassName == "Motor6D" then
motors[i].Enabled = true
end
end
end
end
end
return Ragdoll