Ad
Log in to vote
0

How can I get the body parts using :GetChildren()?

Asked by 1 day ago

Hello!

As the title says, how can I only get the bodyparts using :GetChildren()?

3 answers

Log in to vote
1
Answered by
Ziffixture 6867 Moderation Voter Community Moderator
1 day ago
Edited 1 day ago

Assuming an R15 rig

The character is comprised of MeshParts for its body parts, and a single Part for its HumanoidRootPart. You can check Instance.ClassName for "MeshPart" to act only on the character's body parts, or expand your inclusion by checking if the child is a part in general:

-- Excluding the HumanoidRootPart:
for _, bodyPart in character:GetChildren() do
    if bodyPart.ClassName == "MeshPart" then
        -- ...
    end
end

-- Including the HumanoidRootPart:
for _, bodyPart in character:GetChildren() do
    if bodyPart:IsA("BasePart") then
        -- ...
    end
end

All parts are subclasses of BasePart. Instance:IsA checks not only the class of the instance in question, but if it's a subclass of the given class.

Ad
Log in to vote
0
Answered by 21 hours ago

Check if they are base parts.

local bparts = {}
for i, p in pairs(character:GetChildren()) do
    if p:IsA"BasePart" then
        table.insert(bparts, p)
    end
end
Log in to vote
-1
Answered by 1 day ago

Please do some research

local thingToGetChildrenOff = game.Players.localplayer
R6 = false
R15 = false

for i = 1, thingToGetChildrenOff:GetChildren() do
if R15 == true then
if i.ClassName == "MeshPart" then

--Code Here i = Instance aka an object

end
end

if R6 == true then
if i.ClassName == "Part" then

--Code Here i = Instance aka an object

end
end

end

Answer this question