How do i check all of these variables?

	                    local lowertorso = char:FindFirstChild("LowerTorso")
					    local uppertorso =char:FindFirstChild("UpperTorso")
						local head = char:FindFirstChild("Head")
						local leftupperarm = char:FindFirstChild("LeftUpperArm")
						local leftlowerarm = char:FindFirstChild("LeftLowerArm")
						local lefthand = char:FindFirstChild("LeftHand")
						local leftfoot = char:FindFirstChild("LeftFoot")
						local leftupperleg = char:FindFirstChild("LeftUpperLeg")
						local leftlowerleg = char:FindFirstChild("LeftLowerLeg")		
						local rightupperarm = char:FindFirstChild("RightUpperArm")
						local rightlowerarm = char:FindFirstChild("RightLowerArm")
						local righthand = char:FindFirstChild("RightHand")
						local rightfoot = char:FindFirstChild("RightFoot")
						local rightupperleg = char:FindFirstChild("RightUpperLeg")
						local rightlowerleg = char:FindFirstChild("RightLowerLeg")

how do i check all of these variables without creating a long line of And statements?

if lefthand and right hand and..... so on and on then
---
end

any help?

I think it’d be the best to only get the variable you need most I believed.
May I ask what you are trying to do with these variables? Sorry, I just wanna know why you’d these variables maybe I might be able to provide a solution.

1 Like

Ragdoll on death, just instancing attachments to them

So you’re trying to check if all of the parts exist without creating a long line right?

1 Like

yeah, if i die by falling on the void it will throw an error saying its trying to index ‘nil’ on character because the character is already gone and i dont want that

Maybe just a single Character:FindFirstChild(“HumanoidRootPart”) line? unless you want an extreme way of checking if all of the parts exist.

function CheckForParts(Character)
	local Limbs = {
		"LowerTorso", "UpperTorso", "Head",
		"LeftUpperArm", "LeftLowerArm", "LeftHand",
		"LeftFoot", "LeftUpperLeg", "LeftLowerLeg",
		"RightUpperArm", "RightLowerArm", "RightHand", 
		"RightFoot", "RightUpperLeg", "RightLowerLeg"

	}
	for _,CheckPart in pairs(Character:GetChildren()) do
		if table.find(Limbs, CheckPart.Name) then
			table.remove(Limbs, table.find(Limbs, CheckPart.Name))
		end
	end
	if #Limbs == 0 then
		-- All parts exist
	end
end

Which is kinda unnecessary. In my opinion I’d just put a single line that detects if HumanoidRootPart existed once the Died function has been called.

2 Likes

if humanoid dies and then i just need to check for humanoid root part then it means i dont have to FindFirstChild on all of the limbs?

humanoid.Died:Connect(function()
					local rig = humanoid.RigType
					if rig == rigtype.R15 then
if char:FindFirstChild("HumanoidRootPart") then -- ur saying only this is necesary?
						local lowertorso = char.LowerTorso
						local uppertorso =char.UpperTorso
						local head = char.Head
						-- and then the rest of the bodyparts
2 Likes

Well yes because if a character fell into a void then it’ll delete everything inside a character that counts as a limbs or part.

1 Like

Here’s the code that checks if HumanoidRootPart exist upon a death. It’ll always print “NOT” if the rootpart doesn’t exist basically if you jump into the void.

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		wait()
		Character.Humanoid.Died:Connect(function()
			if Character:FindFirstChild("HumanoidRootPart") then
				print("EXISTED")
			else
				print("NOT")
			end
		end)
	end)
end)

1 Like

well now that explains clearly, btw what recording software u used to post it here because mine usually appear in a download link file

I’m using QuickTime Player on Mac.

1 Like

Not sure if this works. But if it does, it should be a good way to create the constraints without writing the creation code separately for each bodypart.

Edit: I’ve done some edits to this. For example, I had the skipIteration declaration and check in wrong places.

local attachs = {}

for _, v in ipairs(char:GetDescendants()) do
    if v.Name:match("RigAttachment") then
    attachs[#attachs+1] = v
end

local attachsNum = #attachs

-- this variable is used to make sure that
-- attachments that have been used
-- are checked no more times
local skipIteration = false

for i = attachsNum, 1, -1 do
    if skipIteration then
        skipIteration = false
        continue
    end
    
    local attach = attachs[i]
    local loop2Start = i-1
    
    for i2 = loop2Start, 1, -1 do
        local attach2 = attachs[i2]
        if attach2.Name == attach.Name then
            skipIteration = true
            if i2 ~= loop2Start then
                -- related to the same thing as skipIteration
                -- replaces the found attachment in the table with another attachment
                -- the other attachment is skipped on its original index
                -- using skipIteration
                attachs[i2] = attachs[loop2Start]
            end
            
            -- create a ball socket constraint using attach and attach2

            break
        end
    end
end
2 Likes

Ive never seen this :match before, is it the same as just using
v:IsA or v.ClassName == “”?

string.match looks for the other string inside the the first string. v.Name:match("RigAttachment") works the same as string.match(v.Name, "RigAttachment")

It checks if "RigAttachment" is found in the name of the instance. So the condition will be met if the name is "RightShoulderRigAttachment" or "RootRigAttachment", for example.

1 Like