Okay so basically I have NPCs which when they die will ragdoll using this really good ragdoll script I found on the forum:Basic R to Ragdoll Script
But it is clearly intended for Player not NPC so it has a few bugs.
The one I cant fix is that sometimes when it un-ragdolls it thinks its standing but is faceplanting
(Its animating like its standing so the NPC is just horizontal not vertical)
Before anyone says, I’ve looked at other posts before making this one and none of the solutions seem to work and a lot of the posts have not got a solution.
character.Humanoid.BreakJointsOnDeath = false
character.Humanoid.RequiresNeck=false
character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
for _, v in pairs(character:GetDescendants()) do --ragdoll
if v:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v.Enabled = false
end
end
repeat wait() until InhabitantValues.Health.Value > 0 and InhabitantValues.Alive.Value == true
for _,v in pairs(character:GetDescendants()) do --unragdoll
if v:IsA('Motor6D') then
v.Enabled = true
end
if v.Name == 'BallSocketConstraint' then
v:Destroy()
end
if v.Name == 'Attachment' then
v:Destroy()
end
end
character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
character.Humanoid:GetState()
repeat
wait(.1)
character.Humanoid.Jump = true
local State = character.Humanoid:GetState()
until (State ~=Enum.HumanoidStateType.Freefall) and (State ~=Enum.HumanoidStateType.Jumping)
character.Humanoid.BreakJointsOnDeath = true
character.Humanoid.RequiresNeck = true
end
(I added the repeat untill standing function, it doesn’t work )
Thanks for Reading ~ Anon