HumanoidRootPart is not a valid member of Model "Workspace.TabbyCat904"

Hello! I am currently making an obby and I want to player to ragdoll upon death. But for some reason if the player is not touching a part, it will gives me the error in the title.

Here is my code:

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.BreakJointsOnDeath = false
		Character.Humanoid.Died:Connect(function()
			for _, v in pairs(Character:GetDescendants()) do
				if v:IsA("Motor6D") then
					local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
					Attachment0.CFrame = v.C0
					Attachment1.CFrame = v.C1
					Attachment0.Parent = v.Part0
					Attachment1.Parent = v.Part1

					local BallSocketConstraint = Instance.new("BallSocketConstraint")
					BallSocketConstraint.Attachment0 = Attachment0
					BallSocketConstraint.Attachment1 = Attachment1
					BallSocketConstraint.Parent = v.Parent

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

If you think you know what went wrong, please let me know. Have a wonderful day!

1 Like

Changed the 1st line here to:

game.Players.PlayerAdded:Connect(function(Player)

Seems to work fine with that change. Better to call it like that and right away in the script. Even a small delay from code above this line can miss the PlayerAdded trigger. Also maybe something may be spelled wrong in TabbyCat904.

Sorry, but that did nothing. I had already called the Players service at the top of the script as the chunk I sent was farther down.

Try:

Character:WaitForChild(“HumanoidRootPart”).CanCollide = false

Instead of:

Character.HumanoidRootPart.CanCollide = false

It worked! Thank you so much! Have a great day!

1 Like

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