Searching for how to reverse this specific thing

I want to make a script that ragdolls a person any time they get hit. But of course, they cannot stay ragdolled forever. The ragdoll script is perfect, I just want to know how to reverse. Any ragdoll tutorials I’ve seen either only show the ragdoll portion or are just models from the creator marketplace.
This is my code:

for index, joint in pairs(v.Parent:GetDescendants()) do
			if joint:IsA('Motor6D') then
				local socket = Instance.new('BallSocketConstraint')
				local a1 = Instance.new('Attachment')
				local a2 = Instance.new('Attachment')
				a1.Parent = joint.Part0
				a2.Parent = joint.Part1
				socket.Parent = joint.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = joint.C0
				a2.CFrame = joint.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
				joint:Destroy()
				wait(0.4)
				
			end
		end

Please help!

Don’t destroy the joint. If it’s destroyed, you obviously cant re-enable it. So just disable it instead.
not tested

for index, joint in pairs(v.Parent:GetDescendants()) do
	if joint:IsA('Motor6D') then
			local socket = Instance.new('BallSocketConstraint')
			local a1 = Instance.new('Attachment')
			local a2 = Instance.new('Attachment')
			a1.Parent = joint.Part0
			a2.Parent = joint.Part1
			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			joint.Enabled = false
			task.wait(2) -- put in the amount of time you want
			joint.Enabled = true
			socket:Destroy()
		end
	end

Pro tip: Never use wait(). Use task.wait(). Apparently it works better.

https://streamable.com/0de8fh
Yeah I don’t even know anymore.
I pretty much copy-pasted your code, but added PlatformStand and WalkSpeed changes.

v.Parent:FindFirstChild("Humanoid").PlatformStand = true
		fm1de:FireAllClients(player, v)
		v.Parent:WaitForChild("HumanoidRootPart").Orientation = player.Character.HumanoidRootPart.Orientation - Vector3.new(0,180,0)
		hit:Play()
		v.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
		v.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
		for index, joint in pairs(v.Parent:GetDescendants()) do
			if joint:IsA('Motor6D') then
				local socket = Instance.new('BallSocketConstraint')
				local a1 = Instance.new('Attachment')
				local a2 = Instance.new('Attachment')
				a1.Parent = joint.Part0
				a2.Parent = joint.Part1
				socket.Parent = joint.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = joint.C0
				a2.CFrame = joint.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
				joint.Enabled = false
				task.wait(4)
				v.Parent:FindFirstChild("Humanoid").PlatformStand = false
				v.Parent:FindFirstChild("Humanoid").WalkSpeed = 10
				joint.Enabled = true
				socket:Destroy()
			end
		end

(This is the full code btw, not just the ragdoll function)

So does this code fire every time the ragdoll gets punched? Also what does platform stand even do?

Edit: OOOOOHHHHHHHHHHHH

The reason each limb goes limp, then the next, is because it has to wait four seconds to cycle through one limb.

v.Parent:FindFirstChild("Humanoid").PlatformStand = true
fm1de:FireAllClients(player, v)
v.Parent:WaitForChild("HumanoidRootPart").Orientation = player.Character.HumanoidRootPart.Orientation - Vector3.new(0,180,0)
hit:Play()
v.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
v.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
for index, joint in pairs(v.Parent:GetDescendants()) do
	if joint:IsA('Motor6D') then
		local socket = Instance.new('BallSocketConstraint')
		local a1 = Instance.new('Attachment')
		local a2 = Instance.new('Attachment')
		a1.Parent = joint.Part0
		a2.Parent = joint.Part1
		socket.Parent = joint.Parent
		socket.Attachment0 = a1
		socket.Attachment1 = a2
		a1.CFrame = joint.C0
		a2.CFrame = joint.C1
		socket.LimitsEnabled = true
		socket.TwistLimitsEnabled = true
		joint.Enabled = false
		task.delay(4,function() -- put time here
			v.Parent:FindFirstChild("Humanoid").PlatformStand = false
			v.Parent:FindFirstChild("Humanoid").WalkSpeed = 10
			joint.Enabled = true
			socket:Destroy()
		end)
	end
end

So the task.delay function basically lets everything after it fire/do stuff, and everything inside the function/parentheses happens internally, so it doesn’t effect anything outside in terms of waiting. You can even put more task.waits inside of the function if you want. Heck, you can even do it like this:

v.Parent:FindFirstChild("Humanoid").PlatformStand = true
fm1de:FireAllClients(player, v)
v.Parent:WaitForChild("HumanoidRootPart").Orientation = player.Character.HumanoidRootPart.Orientation - Vector3.new(0,180,0)
hit:Play()
v.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
v.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
for index, joint in pairs(v.Parent:GetDescendants()) do
	task.spawn(function() -- I put the SPAWN function here instead
		if joint:IsA('Motor6D') then
			local socket = Instance.new('BallSocketConstraint')
			local a1 = Instance.new('Attachment')
			local a2 = Instance.new('Attachment')
			a1.Parent = joint.Part0
			a2.Parent = joint.Part1
			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			joint.Enabled = false
			task.wait(4)
			v.Parent:FindFirstChild("Humanoid").PlatformStand = false
			v.Parent:FindFirstChild("Humanoid").WalkSpeed = 10
			joint.Enabled = true
			socket:Destroy()
		end
	end)
end

I would honestly recommend you use the second box of code. That way you can put as many task.waits as you want and it will all happen simultaneously. (Technically not though.)

FYI spawn just immediately fires the function, and delay you can put a number for a delay. (duh)

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