I would like to loop through any character model and get their Arms. I’m looking for a method that doesn’t require me already knowing the Arms name and Path as most if not all character models are different.
My current idea is to match the name “Arm” to every child in character.
I’ve used string.match and string.find require the word to be separate from other words it seems.
Also, I am not trying to loop through each letter of the name, even though it would be easier to do. I want to have as minimal loops as I can.
-- Function to check if a string contains a substring
local function containsSubstring(str, substr)
return string.find(str:lower(), substr:lower(), 1, true) ~= nil
end
-- Function to recursively search and print parts of a model
local function printParts(model)
for _, part in ipairs(model:GetChildren()) do
if part:IsA("BasePart") then
if containsSubstring(part.Name, "arm") then
print("Found part with 'arm' in name:", part.Name)
end
end
-- Recursively search child models
if part:IsA("Model") then
printParts(part)
end
end
end
-- Get the model by name
local model = game:GetService("Workspace"):FindFirstChild("Drooling Zombie")
printParts(model)