Undoing a Ragdoll

so i found this ragdoll script on the toolbox, but does anyone know how to make the player get up after a bit?
Edit: im warning you, the code is long

	script.Parent.Humanoid.Died:Connect(function(var)
		local randomSound = math.random(1, 6)
		for i, v in pairs(script.Parent.DeathSounds:GetChildren()) do
			if i == randomSound then
				v:Play()
			end
		end
		function getAttachment0(attachmentName)
			for _,child in next,script.Parent:GetChildren() do
				local attachment = child:FindFirstChild(attachmentName)
				if attachment then
					return attachment
				end
			end
		end
		local removeHRP = true
		local head = script.Parent["Head"]
		local leftarm = script.Parent["Left Arm"]
		local leftleg = script.Parent["Left Leg"]
		local rightleg = script.Parent["Right Leg"]
		local rightarm = script.Parent["Right Arm"]
		local torso = script.Parent.Torso
		local root =script.Parent.HumanoidRootPart
		local camera = workspace.CurrentCamera
		if camera.CameraSubject == script.Parent.Humanoid then
			camera.CameraSubject = script.Parent.Torso
		end
		if removeHRP == true then
			root:Destroy()
		end
		local impactH = script.ImpactSound:Clone()
		impactH.Parent = head
		impactH.Disabled = false
		local impactLA = script.ImpactSound:Clone()
		impactLA.Parent = leftarm
		impactLA.Disabled = false
		local impactRA = script.ImpactSound:Clone()
		impactRA.Parent = rightarm
		impactRA.Disabled = false
		local rootA =Instance.new("Attachment")
		local HeadA = Instance.new("Attachment")
		local LeftArmA = Instance.new("Attachment")
		local LeftLegA = Instance.new("Attachment")
		local RightArmA = Instance.new("Attachment")
		local RightLegA = Instance.new("Attachment")
		local TorsoA = Instance.new("Attachment")
		local TorsoA1 = Instance.new("Attachment")
		local TorsoA2 = Instance.new("Attachment")
		local TorsoA3 = Instance.new("Attachment")
		local TorsoA4 = Instance.new("Attachment")
		local TorsoA5 = Instance.new("Attachment")
		function set1()
			HeadA.Name = "HeadA"
			HeadA.Parent = head
			HeadA.Position = Vector3.new(0, -0.5, 0)
			HeadA.Rotation = Vector3.new(0, 0, 0)
			HeadA.Axis = Vector3.new(1, 0, 0)
			HeadA.SecondaryAxis = Vector3.new(0, 1, 0)
			LeftArmA.Name = "LeftArmA"
			LeftArmA.Parent = leftarm
			LeftArmA.Position = Vector3.new(0.5, 1, 0)
			LeftArmA.Rotation = Vector3.new(0, 0, 0)
			LeftArmA.Axis = Vector3.new(1, 0, 0)
			LeftArmA.SecondaryAxis = Vector3.new(0, 1, 0)
			LeftLegA.Name = "LeftLegA"
			LeftLegA.Parent = leftleg
			LeftLegA.Position = Vector3.new(0, 1, 0)
			LeftLegA.Rotation = Vector3.new(0, 0, 0)
			LeftLegA.Axis = Vector3.new(1, 0, 0)
			LeftLegA.SecondaryAxis = Vector3.new(0, 1, 0)
			RightArmA.Name = "RightArmA"
			RightArmA.Parent = rightarm
			RightArmA.Position = Vector3.new(-0.5, 1, 0)
			RightArmA.Rotation = Vector3.new(0, 0, 0)
			RightArmA.Axis = Vector3.new(1, 0, 0)
			RightArmA.SecondaryAxis = Vector3.new(0, 1, 0)
			RightLegA.Name = "RightLegA"
			RightLegA.Parent = rightleg
			RightLegA.Position = Vector3.new(0, 1, 0)
			RightLegA.Rotation = Vector3.new(0, 0, 0)
			RightLegA.Axis = Vector3.new(1, 0, 0)
			RightLegA.SecondaryAxis = Vector3.new(0, 1, 0)
			rootA.Name= "rootA"
			rootA.Parent = root
			rootA.Position = Vector3.new(0, 0, 0)
			rootA.Rotation = Vector3.new(0, 90, 0)
			rootA.Axis = Vector3.new(0, 0, -1)
			rootA.SecondaryAxis = Vector3.new(0, 1, 0)
		end
		function set2()
			TorsoA.Name = "TorsoA"
			TorsoA.Parent = torso
			TorsoA.Position = Vector3.new(0.5, -1, 0)
			TorsoA.Rotation = Vector3.new(0, 0, 0)
			TorsoA.Axis = Vector3.new(1, 0, 0)
			TorsoA.SecondaryAxis = Vector3.new(0, 1, 0)
			TorsoA1.Name = "TorsoA1"
			TorsoA1.Parent = torso
			TorsoA1.Position = Vector3.new(-0.5, -1, 0)
			TorsoA1.Rotation = Vector3.new(0, 0, 0)
			TorsoA1.Axis = Vector3.new(1, 0, 0)
			TorsoA1.SecondaryAxis = Vector3.new(0, 1, 0)
			TorsoA2.Name = "TorsoA2"
			TorsoA2.Parent = torso
			TorsoA2.Position = Vector3.new(-1, 1, 0)
			TorsoA2.Rotation = Vector3.new(0, 0, 0)
			TorsoA2.Axis = Vector3.new(1, 0, 0)
			TorsoA2.SecondaryAxis = Vector3.new(0, 1, 0)
			TorsoA3.Name = "TorsoA3"
			TorsoA3.Parent = torso
			TorsoA3.Position = Vector3.new(1, 1, 0)
			TorsoA3.Rotation = Vector3.new(0, 0, 0)
			TorsoA3.Axis = Vector3.new(1, 0, 0)
			TorsoA3.SecondaryAxis = Vector3.new(0, 1, 0)
			TorsoA4.Name = "TorsoA4"
			TorsoA4.Parent = torso
			TorsoA4.Position = Vector3.new(0, 1, 0)
			TorsoA4.Rotation = Vector3.new(0, 0, 0)
			TorsoA4.Axis = Vector3.new(1, 0, 0)
			TorsoA4.SecondaryAxis = Vector3.new(0, 1, 0)
			TorsoA5.Name = "TorsoA5"
			TorsoA5.Parent = torso
			TorsoA5.Position = Vector3.new(0, 0, 0)
			TorsoA5.Rotation = Vector3.new(0, 90, 0)
			TorsoA5.Axis = Vector3.new(0, 0, -1)
			TorsoA5.SecondaryAxis = Vector3.new(0, 1, 0)
		end
		function set3()
		end
		spawn(set1);
		spawn(set2);
		local HA = Instance.new("HingeConstraint")
		HA.Parent = head
		HA.Attachment0 = HeadA
		HA.Attachment1 = TorsoA4
		HA.Enabled = true
		HA.LimitsEnabled=true
		HA.LowerAngle=0
		HA.UpperAngle=0
		local LAT = Instance.new("BallSocketConstraint")
		LAT.Parent = leftarm
		LAT.Attachment0 = LeftArmA
		LAT.Attachment1 = TorsoA2
		LAT.Enabled = true
		LAT.LimitsEnabled=true
		LAT.UpperAngle=90
		local RAT = Instance.new("BallSocketConstraint")
		RAT.Parent = rightarm
		RAT.Attachment0 = RightArmA
		RAT.Attachment1 = TorsoA3
		RAT.Enabled = true
		RAT.LimitsEnabled=true
		RAT.UpperAngle=90
		local HA = Instance.new("BallSocketConstraint")
		HA.Parent = head
		HA.Attachment0 = HeadA
		HA.Attachment1 = TorsoA4
		HA.Enabled = true
		local TLL = Instance.new("BallSocketConstraint")
		TLL.Parent = torso
		TLL.Attachment0 = TorsoA1
		TLL.Attachment1 = LeftLegA
		TLL.Enabled = true
		TLL.LimitsEnabled=true
		TLL.UpperAngle=90
		local TRL = Instance.new("BallSocketConstraint")
		TRL.Parent = torso
		TRL.Attachment0 = TorsoA
		TRL.Attachment1 = RightLegA
		TRL.Enabled = true
		TRL.LimitsEnabled=true
		TRL.UpperAngle=90
		local RTA = Instance.new("BallSocketConstraint")
		RTA.Parent = root
		RTA.Attachment0 = rootA
		RTA.Attachment1 = TorsoA5
		RTA.Enabled = true
		RTA.LimitsEnabled=true
		RTA.UpperAngle=0
		head.Velocity = head.CFrame.lookVector*30

		for _,child in next,script.Parent:GetChildren() do
			if child:IsA("Accoutrement") then
				for _,part in next,child:GetChildren() do
					if part:IsA("BasePart") then
						part.Parent = script.Parent
						child:remove()
						local attachment1 = part:FindFirstChildOfClass("Attachment")
						local attachment0 = getAttachment0(attachment1.Name)
						if attachment0 and attachment1 then
							local constraint = Instance.new("HingeConstraint")
							constraint.Attachment0 = attachment0
							constraint.Attachment1 = attachment1
							constraint.LimitsEnabled = true
							constraint.UpperAngle = 0
							constraint.LowerAngle = 0
							constraint.Parent = script.Parent
						end
					end
				end
			end
		end
end
2 Likes

Yes. To make your player get up after a bit you need to include a delay function in your script. After the ragdoll effect, use wait() function to wait for a certain period of time, then apply reverse action to your script. Here’s how;

Just below the last line of your code, you need to create a function that resets the character after a certain period of time:

wait(10) --This will wait for 10 seconds. You can adjust this to any amount of seconds that you prefer

for i , joint in pairs(script.Parent:GetDescendants()) do
	if joint:IsA("BallSocketConstraint") or joint:IsA("HingeConstraint") then
		joint:Destroy()
	end
end

local anim = Instance.new('Animation')
anim.AnimationId = "rbxassetid://130140446"
local track = script.Parent.Humanoid:LoadAnimation(anim)
track:Play()

for i, child in pairs(script.Parent:GetDescendants()) do
	if child.ClassName == "Motor6D" then
		child.CurrentAngle = child.RestAngle -- Reseting all the joints
	end
end

local HRP = script.Parent.HumanoidRootPart --reference to HumanoidRootPart
HRP.Position = Vector3.new(0, 3.5, 0)

Note the Animation id, you need to put the correct id of the stand up animation. Be sure to test your code and then reply

1 Like

i dont think you read it all, which, i wouldnt either its pretty long, but there isnt supposed to be a get up animation, and the humanoid root part gets destroyed in the script so this wouldnt work

i urgently need help with this

1 Like

It looks like this ragdoll script is designed specifically to ragdoll the player when they die, which is why the player can’t get up afterwards. I’d recommend using a different ragdoll script instead, such as Ragdoll Script R15 and R6 [PC, Mobile, Xbox].

yeah i know, but i can easily change that. i tried this one but i feel like its far too complicated for me as i dont know how to make the player ragdoll and unragdoll on command, and sometimes theres a delay when you try ragdolling or unragdolling

I don’t mean to be rude, but if you can’t understand the linked script then perhaps you should take a step back and learn more about the fundamentals of Lua programming instead of diving in head first.

listen i dont want to be rude here either, but just because i dont know one thing, doesnt mean i dont know anything. i think its pretty annoying when people think i havent already took the time to learn some stuff before asking. also, correction on my end, i DO know how to make the player ragdoll on command, i just cant make them UNragdoll on command.

Here’s my new suggestion:

wait(10) -- or anything u prefer

-- Removing the constraints and resetting the character.
for i, object in pairs(script.Parent:GetChildren()) do
	if object:IsA('HingeConstraint') or object:IsA('BallSocketConstraint') then
		object:Destroy()
	end
end

-- Setting the character upright.
script.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.HumanoidRootPart.Position) 

-- Reapplying Motor6D joints.
for i, joint in pairs(script.Parent:GetChildren()) do
	if joint:IsA('Motor6D') then
		joint:Destroy()
	end
end

local function createMotor(part0, part1)
    local motor = Instance.new("Motor6D")
    motor.Part0 = part0
    motor.Part1 = part1
    motor.Parent = part0
end

createMotor(script.Parent.Torso, script.Parent.Head)
createMotor(script.Parent.Torso, script.Parent["Left Arm"])
createMotor(script.Parent.Torso, script.Parent["Right Arm"])
createMotor(script.Parent.Torso, script.Parent["Left Leg"])
createMotor(script.Parent.Torso, script.Parent["Right Leg"])
createMotor(script.Parent.Torso, script.Parent["HumanoidRootPart"])

This will wait for ten seconds after death, then restore the character’s joints, remove existing constraints, and restore the HumanoidRootPart, effectively making them stand up without an animation. Also, it’s only for r6, keep in mind.

Screen Shot 2023-10-15 at 6.37.35 PM
i had told you that the HRP gets destroyed

No need to remove and then create Motor6Ds, my game Wubby handles ragdolls pretty well by just disabling the character’s Motor6Ds:

task.wait(10) -- superior than wait(10)

-- disabling the constraints and resetting the character.
for i, object in pairs(script.Parent:GetChildren()) do
	if object:IsA('HingeConstraint') or object:IsA('BallSocketConstraint') then
		object.Enabled = false
	end
end

-- Setting the character upright.
script.Parent:PivotTo( CFrame.new(script.Parent.HumanoidRootPart.Position))

-- but honestly I prefer this method:
-- script.Parent.Humanoid:ChangeState(Enum.HumanoidState.GettingUp)

-- Reenable Motor6D joints.
for i, joint in pairs(script.Parent:GetChildren()) do
	if joint:IsA('Motor6D') then
		joint.Enabled = true
	end
end

I don’t really think you should use that ragdoll script you saw on the toolbox as that is VERY ancient code (pre BreakJointsOnDeath addition), you should use this script instead (disable BreakJointsOnDeath on the humanoid):

Just disable the Motor6Ds, replace them by BallSocketConstraints. If you want to wake up the character, do it the other way round: enable Motor6Ds, destroy BallSocketConstraints

If you have any questions, please ask me as I spent weeks perfecting ragdolls for my game

woah. youre a lifesaver. thank you so much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.