i want to group multiple parts with different names into one model, which i have sort-of achieved using the following script:
for i,v in pairs(workspace:GetChildren())do
if v.Name == "PartA" then
v.Parent = workspace.Model
elseif v.Name == "PartB" then
v.Parent = workspace.Model
elseif v.Name == "PartC" then
v.Parent = workspace.Model
elseif v.Name == "PartD" then
v.Parent = workspace.Model
elseif v.Name == "PartE" then
v.Parent = workspace.model
end
end
but i want to make this script more efficient, i.e use less lines of code.
i considered using table.find but i have no idea how to implement it into a script like this. are there other ways to reduce the lines of code on this?
for i, v in pairs(workspace:GetFullName()) do
if v.Name:find("Part") then -- if finds "Part" in v.Name then (so this will work for anything that has Part in its name)
v.Parent = workspace.Model
end
end