Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Need help making my ragdoll and unragdoll script, unragdoll doesn't work as well?

Heyo! Today I am making a R to ragdoll thing but I can't seem to make the unragdoll work and the ragdoll floats up instead of having gravity.

Sorry for the dogey title, had to add a question mark.

Here is the death script:

local function ragdoll(c)
	for _, v in pairs(c:GetDescendants()) do
		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:Destroy()
			for e, v in pairs(c:GetChildren()) do
				if v:IsA("Part") then
					v.CanCollide = true
				end
			end
		end
	end
	c.Head.CanCollide = true
	c.HumanoidRootPart.CanCollide = false
end

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(ch)
		ch.Humanoid.BreakJointsOnDeath = false
		ch.Humanoid.Died:Connect(function()
			ragdoll(ch)
		end)
	end)
end)

And I am trying to convert it. Here is the currently "converted" script

local function ragdoll(c)
	for _, v in pairs(c:GetDescendants()) do
		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:Destroy()
			for e, v in pairs(c:GetChildren()) do
				if v:IsA("Part") then
					v.CanCollide = true
				end
			end
		end
	end
	c.Head.CanCollide = true
	c.HumanoidRootPart.CanCollide = false
end

local function unragdoll(c)
	for _, v in pairs(c:GetDescendants()) do
		if v:IsA("BallSocketConstraint") or v:IsA("Attachment") then
		v:Destroy()
		end
	end
end

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(ch)
		wait(4)
		ragdoll(ch)
		wait(4)
		unragdoll(ch)
	end)
end)

Any help on making the ragdoll not float and a unragdoll? The current unragdoll just kills the player. Taking off the Attachments/BSocketConstraints from a body part causes it to just fall off.

NOTE: I think it keeps loop-ragdolling some odd reason.

1 answer

For making the ragdoll not float, I'd turn on PlatformStand for the humanoid of the ragdoll. As for actually restoring the normal state, I would store the joints in some kind of folder and restore them when you see fit.

8 comments

0

How would I do that?

0

Also I turned off platform stand but it did nothing

0

And platform stand is already off

0

You'd just make the ballsocket's parent v's Parent and put v in smth like replicated or server storage, then when you wanna, place the motor6ds back by inserting them based on the name of the attachments

0

Ah ok

0

Wait I turned on platFormStand and it helped hang on.

0

yeah mb, i meant on at first

0

Now the camera goes crazy (moving with the arms) and arms go through the floor AND the player still has footstep sounds and last but not least, I dont know how to I would parent all the stuff to a folder

This discussion is preserved as it was. New answers, comments, and votes are closed.