Hey there! As the title states, I’m currently having issues with the :GetDescendants method. When I print the partDirectory’s descendants, I am given a table consisting of all instances that are under partDirectory. However, when I make an attempt to loop through them, I am greeted with only two instances. What could be causing this issue; what am I doing wrong?
Thanks in advance.
My script:
function Radon:HandleTransparency(partTransparency : number, partDirectory : Instance)
if #self.TransparentParts>0 then
for i, v in pairs(self.TransparentParts) do
v.Transparency = partTransparency --//Set the transparency of the instance to the partTransparency variable, which is a defined number
end
return
end
table.insert(self.TransparentParts,self.Character["Right Arm"])
table.insert(self.TransparentParts,self.Character["Left Arm"])
for i, v in pairs(partDirectory:GetDescendants()) do --//Loop through all instances present inside of the given directory
local v = partDirectory:GetDescendants()[i]
print(v.Name)
if (not v:IsA("BasePart") and not v:IsA("MeshPart")) or (partTransparency==1 and v.Transparency==1) then
return --//Return if the instance is not a basepart, a meshpart, or if the instance is meant to be transparent
end
v.Transparency= partTransparency --//Set the transparency of the instance to the partTransparency variable, which is a defined number
table.insert(self.TransparentParts, v); --//Insert the instance into the 'AfflictedParts' table
end
end