How do I get the parts of a dummy that aren't apart of the original rig?

I am trying to get all of the parts in a dummy that aren’t native to the original rig like an arm or leg, but for some reason my code isn’t working properly. I placed a part in the dummy called “Outlier” and it isn’t printing anything at all. Please help, and thanks in advance.

Here’s the code.

hrp = script.Parent:WaitForChild('HumanoidRootPart')
local rigParts = {
	head = script.Parent.Head,
	leftArm = script.Parent["Left Arm"],
	rightArm = script.Parent["Right Arm"],
	leftLeg = script.Parent["Left Leg"],
	rightLeg = script.Parent["Right Leg"],
	torso = script.Parent.Torso,
	hum = script.Parent.Humanoid,
	position = script.Parent.Position
}

for _,outliers in pairs(script.Parent:GetChildren()) do
	for _,rigBits in pairs(rigParts) do
		if outliers == rigBits or hrp then return end
		print(outliers.Name)
	end
end

Feel free to ask for clarification if needed :+1:

Think your issue is happening here. The code basically checking if outliers is equal to rigBits or hrp is truthy (Not false or nil), which if it got to this part, means it is true.

Did you mean to check if outliers is equal to hrp?

Also, change the return to a continue so it’ll go to the next iteration rather than stop the loop entirely

1 Like

Yes, I did mean to check if outliers == hrp, but now it’s printing everything seven times and ‘Outlier’ eight times after the change. This is the new code incase I made a mistake:

if outliers == rigBits or outliers == hrp then continue end
		print(outliers.Name)

That seems to be how it should be unless I’m wrong, what do you mean by this part?

1 Like

It’s printing this:

:arrow_forward: Torso (x7) - Server - Position:16
:arrow_forward: Left Leg (x7) - Server - Position:16
:arrow_forward: Right Leg (x7) - Server - Position:16
:arrow_forward: Left Arm (x7) - Server - Position:16
:arrow_forward: Right Arm (x7) - Server - Position:16
:arrow_forward: Head (x7) - Server - Position:16
:arrow_forward: Humanoid (x7) - Server - Position:16
:arrow_forward: Position (x7) - Server - Position:16
:arrow_forward: Outlier (x8) - Server - Position:16

Edit: I copy & pasted directly which is why the arrows look like that

You might need to change how you do the loops

A way I found that worked for me was to

  • Make a variable before the rigParts loop with a value of false, this will be used to check if we found this part in our exclusions
  • In the rigParts loop, we check if part is in the table or is a humanoidrootpart, if it is, we change our variable to true
  • Outside the loop now, we check if our variable is false, if it is, it means this part isn’t part of the original rig, otherwise we don’t care as it’s part of the original rig
hrp = script.Parent:WaitForChild('HumanoidRootPart')
local rigParts = {
	head = script.Parent.Head,
	leftArm = script.Parent["Left Arm"],
	rightArm = script.Parent["Right Arm"],
	leftLeg = script.Parent["Left Leg"],
	rightLeg = script.Parent["Right Leg"],
	torso = script.Parent.Torso,
	hum = script.Parent.Humanoid,
}

for _,outliers in pairs(script.Parent:GetChildren()) do
	local foundInParts = false
	for _,rigBits in pairs(rigParts) do
		if outliers ~= rigBits and outliers ~= hrp then 
			continue
		end
		foundInParts = true
		break
	end
	
	if foundInParts then
		continue
	end
	
	print(outliers.Name)
end
1 Like

Here is also code that will work, which is a bit simpler than @EmbatTheHybrid 's but after all does the same:

local dummy = script.Parent;
local HumRootPart = dummy:WaitForChild('HumanoidRootPart');

local rigParts = {
	head = script.Parent.Head,
	leftArm = script.Parent["Left Arm"],
	rightArm = script.Parent["Right Arm"],
	leftLeg = script.Parent["Left Leg"],
	rightLeg = script.Parent["Right Leg"],
	torso = script.Parent.Torso,
	humanoid = script.Parent.Humanoid
}

for _, dummyPart in pairs(dummy:GetChildren()) do
	local isRigPart = false
	
	for _, rigPart in pairs(rigParts) do
		if dummyPart == rigPart or dummyPart == HumRootPart then
			isRigPart = true
			break;
		end;
	end;

	if not isRigPart then
		print(dummyPart.Name)
	end;
end;
1 Like

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