I am reworking a ragdoll thingamabob I made for myself - with an implemented getting up animation but here’s the thing:
It’s not quite functioning how I wish. For it to work - the player must have ragdolled while standing. How do I make it play seamlessly (and without colliding with the ground and stuff)?
Code:
function rgModule:Unragdoll(character: Model)
local hrp = character:FindFirstChild("HumanoidRootPart")
local hum = character:FindFirstChild("Humanoid")
local plr = game:GetService("Players"):GetPlayerFromCharacter(character)
-- ////////////////////////////////////////////////////////////////////////// --
if character == nil then error("Character was not defined in function <Unragdoll>. Double-check your code!", 2) return end
for i,socket in pairs(character:GetDescendants()) do
if socket:IsA("BallSocketConstraint") then
socket:Destroy()
for i,attachment in pairs(character:GetDescendants()) do
if attachment:IsA("Attachment") and attachment.Name == "RagdollAttachment" then
attachment:Destroy()
end
end
for i,joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
end
end
print("Unragdolled!")
event:FireClient(plr, false)
local animID = "rbxassetid://110657831082635"
local animator = hum:FindFirstChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = animID
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play(0.3)
end
You could anchor the humanoidrootpart once the animation starts to play. This would make the character stay in place for the animation to play, then ofc unanchor it once it finsihes