Hello!
As the title says, how can I only get the bodyparts using :GetChildren()?
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.
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
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