Why does this keep on saying " thing is nil " even though it's the line that supports it if it's nil?

Hi! my name is bullet, and i’ve just been having too many errors on this one line of code.

it works on the first run, but then if you get knocked down again and you jump up and the same thing happens again: this pops up.

it keeps on saying that " parent is nil " or " name is nil " even though it is literally the line of code built to help define it.

i’ve been working on a ragdoll script for context, and this is a snippet of the code that is erroring [ the part where it says if nil then return end ]

for i,v in pairs(humanoid.Parent:GetDescendants()) do
	if v:IsA("BallSocketConstraint") then
		v.UpperAngle = 0
		v.TwistUpperAngle = 0
		v.TwistLowerAngle = 0
		local Joints = Instance.new("Motor6D",v.Parent)
					
					
	
					
        if v.Attachment1.Parent.Name == nil or v.Attachment1.Parent == nil or v.Attachment1 == nil then -- part that errors every single time i run the code [ after one time ]
           print("nil")
        return end

i still just don’t get why it’s doing this

thanks for reading, and please help!

If there’s no parent then it can’t see if there’s a name…

1 Like

i actually fixed it, now it prints nil but now it only sits you normally, so i guess i’ll just mark this as the solution and carry it on to another post

thank you for your time

Okay, no problem! Have a good day.

1 Like