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
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
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)
Torso (x7) - Server - Position:16
Left Leg (x7) - Server - Position:16
Right Leg (x7) - Server - Position:16
Left Arm (x7) - Server - Position:16
Right Arm (x7) - Server - Position:16
Head (x7) - Server - Position:16
Humanoid (x7) - Server - Position:16
Position (x7) - Server - Position:16
Outlier (x8) - Server - Position:16
Edit: I copy & pasted directly which is why the arrows look like that
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
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;