How do I make a Ragdoll on death script?

I’m trying to make a ragdoll on death script. But the script I’m using has this error

Attatchment0 is not a valid member of BallSocketConstraint “BallSocketConstraint”

And the ragdoll is very stiff

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		Char:WaitForChild("Humanoid").BreakJointsOnDeath = false
		Char.Humanoid.Died:Connect(function()
			for _, v in pairs(Char:GetDescendants()) do
				if v:IsA("Motor6D") then
					local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
					Att0.CFrame = v.C0
					Att1.CFrame = v.C1
					Att0.Parent = v.Part0
					Att1.Parent = v.Part1
					local BSC = Instance.new("BallSocketConstraint")
					BSC.Attatchment0 = Att0
					BSC.Attachment1 = Att1
					BSC.Parent = v.Part0

					v:Destroy()
				end
			end
			Char.HumanoidRootPart.CanCollide = false
		end)
	end)
end)

This is a server script in ServerScriptService.

The only mistake you made was because you accidentally wrote “Attatchment0” instead of “Attachment0”. Not big problem.

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		Char:WaitForChild("Humanoid").BreakJointsOnDeath = false
		Char.Humanoid.Died:Connect(function()
			for _, v in pairs(Char:GetDescendants()) do
				if v:IsA("Motor6D") then
					local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
					Att0.CFrame = v.C0
					Att1.CFrame = v.C1
					Att0.Parent = v.Part0
					Att1.Parent = v.Part1
					local BSC = Instance.new("BallSocketConstraint")
					BSC.Attachment0 = Att0 --// Here
					BSC.Attachment1 = Att1
					BSC.Parent = v.Part0

					v:Destroy()
				end
			end
			Char.HumanoidRootPart.CanCollide = false
		end)
	end)
end)

thanks, I probably should have just checked the script for mistakes

1 Like

Your welcome!! I’m happy to have helped you.

1 Like

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