Hi all. I’m writing to query about ragdoll issues which I’d like some advice about. I’ve been working on a game for a long time now and I’ve come to face this problem that there may be a chance of the ragdoll bugging out, which leads to either the player or NPC to not be able to get up regardless. I’m not sure why and I’ve tried alot of different approaches to try to fix the issue. I’m not sure if this is concerning ragdoll itself, advice would be greatly appreciated. Thanks
function StopRagdoll(Zombie)
for i,v in pairs(Zombie:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v:Destroy()
end
if v:IsA("Motor6D") then
v.Enabled = true
end
end
end
function ZombieFunc.Ragdoll(Zombie)
if Zombie then
local Humanoid = Zombie:FindFirstChild("Humanoid")
if Humanoid then
if Humanoid:GetAttribute("Ragdolled") then return end
if Humanoid:GetAttribute("KnockbackResistance") then return end
for i,v in pairs(Zombie:GetDescendants()) do
if v:IsA("Motor6D") then
local ballSocketConstraint = Instance.new("BallSocketConstraint")
local attachment0 = Instance.new("Attachment")
local attachment1 = Instance.new("Attachment")
attachment0.Parent = v.Part0
attachment1.Parent = v.Part1
ballSocketConstraint.Parent = v.Parent
ballSocketConstraint.Attachment0 = attachment0
ballSocketConstraint.Attachment1 = attachment1
attachment0.CFrame = v.C0
attachment1.CFrame = v.C1
ballSocketConstraint.LimitsEnabled = true
ballSocketConstraint.TwistLimitsEnabled = true
v.Enabled = false
end
end
if Humanoid and Humanoid.Health > 0 then
Humanoid:SetAttribute("Ragdolled", true)
local Recover
local Potential_Player = game.Players:GetPlayerFromCharacter(Zombie)
if Potential_Player then
ChangePlayerState:FireClient(Potential_Player, "Down")
wait(4)
StopRagdoll(Zombie)
task.spawn(function()
Recover = Humanoid.Animator:LoadAnimation(RS.ZombieAnimations.Default.Recover)
Recover.Priority= Enum.AnimationPriority.Action4
Recover:Play()
end)
ChangePlayerState:FireClient(Potential_Player, "Recover")
wait(2.5)
Humanoid:SetAttribute("Ragdolled", false)
elseif not Potential_Player then
Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
wait(4)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
StopRagdoll(Zombie)
task.spawn(function()
Recover = Humanoid.Animator:LoadAnimation(RS.ZombieAnimations.Default.Recover)
Recover.Priority= Enum.AnimationPriority.Action4
Recover:Play()
end)
wait(1.5)
Humanoid:SetAttribute("Ragdolled", false)
elseif not Zombie then
warn("Zombie not found.")
end
end
end
end
end